Issue with .htaccess rewrite

Avatar
  • Answered
Hi There

On the shared hosting I have been trying to rewite my urls however I have come across a difficault situation with a very simple rule that may be as a result of mod_dir.

If I try to write my urls to a variable that I can use internally with PHP like so:

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?var=$1 [QSA,L]

Everything works great until the request conflicts with an actual folder path for example:

http://mydomain/conflict

sends my scripts var=conflict but... if there is a folder named 'conflict' firstly this happens:

http://mydomain/conflict/ (a forward slash is appened most likly a result of mod_dir)

And with my htaccess when the page is forwarded this happens:

http://mydomain/conflict/?var=conflict

This ofcourse reveals not only a directory presence but also any type of request string, I am unable to negate mod_dir in the htaccess rules and I'm not certain that switching off the forwardslash is a secure thing to do.

I have even tried -MultiViews in the htaccess with no luck, is there any way in the htaccess to force the server configuration to ignore certain folders when handling rewritten requests or is there some specific way to write this that doesnt conflict with the server configuration ?

Thanks :D
Avatar
Scott
Hello, While you can disable specific directives using htaccess, you may not be able to stop the behavior you are experiencing. Of course, on a shared server, the disabling of mod_dir is not possible. Kindest Regards, Scott M