Forum Moderators: phranque

Message Too Old, No Replies

Why does the url rewrites to index although im disabling it?

         

a naguib 2000

6:19 pm on Jul 29, 2007 (gmt 0)

10+ Year Member



Hi all,
This is my first post in this forum and i have a little problem with mod_rewrite.. I have the .htaccess file with these lines in it:

RewriteEngine On

RewriteCond %{REQUEST_URI}!^ar/? [NC]
RewriteRule ^(.+)$ index.php?pname=$1 [L]

RewriteCond %{REQUEST_URI} ^/ar [NC]
RewriteRule .* 403.shtml [F,L]

the problem is that when writing www.example.com/ar it goes to the index.php page and i find that the $_GET variable is index.php so what is the problem i don't want the engine to rewrite the ar to the index.php..

thank you

jdMorgan

3:31 am on Jul 30, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Along with an error in the first RewriteCond pattern (missing leading slash), you've got a rewrite loop in there. index.php will be repeatedly rewritten to itself, therefore the pname GET parameter value will be "index.php". I'd suggest:

ErrorDocument 403 /403.shtml
#
RewriteEngine on
#
RewriteCond %{REQUEST_URI}!^/ar/? [NC]
RewriteCond %{REQUEST_URI}!^/index\.php$
RewriteRule (.+) index.php?pname=$1 [L]
#
RewriteRule ^ar/? - [F]

The second rule does not need a RewriteCond, use the RewriteRule pattern instead. The [F] flag, by itself, will immediately invoke your 403 ErrorDocument. There is no need to rewrite the URL to 403.shmtl or to use the [L] flag.

Jim

a naguib 2000

5:47 am on Jul 30, 2007 (gmt 0)

10+ Year Member



Thanx alot jdMorgan.. It really helped..

Another question please...

ar/ is a directory in my website.. I have two .htaccess files, one inside the ar directory and the other in upper directory..

now when I try to access the ar directory using www.example.com/ar without the trailing slash it gives me a bad request 400..
I tried alot of solutions found in this forums but it didnt work..
Is there a problem to have two .htaccess, one inside the other?