views:

25

answers:

2

Yeah, mod_rewrite is driving me crazy.

Here is the problem:

my htaccess

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

when i try to access the page advantix (so address was www.mywebsite.com/advantix), i'm being redirected to advantix/?url=advantix

Looking at the access log, i have a suspicious 301 in the middle

"GET /advantix HTTP/1.1" 301 335 "-" "Mozilla/5.0"
"GET /advantix/?url=advantix HTTP/1.1" 200 186 "-" "Mozilla/5.0"

There is one important detail: advantix is a directory.

So, if i comment that rule, advantix goes to the folder and list the files.

Why it applies automatically the / if there's a folder matching?

I don't want to reach the folder, i want to reach index.php?url=advantix with a call to advantix.

I have the rewriteLogs too, but they didn't help more. My vhost conf has Directory tag with Options All, if helps, i don't know much about that.

A: 

Try this once:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$    index.php?url=$1 [L,QSA]
Eric Petroelje
this obviously take me to the folder listing, and i don't want this.
avastreg
+1  A: 

Turn off the DirectorySlash Apache directive. This seems to be causing the 301 redirect.

DirectorySlash Off
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [L,QSA]
Ramesh Tabarna
thank you, it works. i didn't found that directive!
avastreg
no problem. although i was aware of this functionality but was not aware of the exact directive till now.
Ramesh Tabarna