I’m working with htaccess in a php application. I want some behavior like this:
- Send request to mydomain.com/login
- Have htaccess intercept the request to login and send to index.php?ref=login
However I have that all set up and for some reason it automatically sends the mydomain.com/login request directly to login.php without going through index.php.
I think maybe there is some configuration interfering here? For reference my .htaccess looks like this:
Options +SymLinksIfOwnerMatch
RewriteEngine On
Options -Indexes
RewriteRule ^news$ /index.php?ref=news [NC,L]
RewriteRule ^login$ /index.php?ref=login [NC,L]
The news url rewriting works fine and routes it through index.php … but I have no news.php and suspect that If i did there would be an issue there.
I also apologize if this question is in the wrong spot, I’m not sure if it belongs over at superuser or serverfault.
You likely have
MultiViewsturned on. When you send a request for/loginto the server, it gets handled bymod_negotiationbefore yourRewriteRuleis correctly applied.Since
MultiViewsis enabled, and the resource/logindoes not exist, it looks for an existing resource to map it to – In this case,/login.php. This is later passed to yourRewriteRuledirectives, but since they’re looking for the original URL, no match is found, and no rewrite is performed.Disabling
MultiViewsshould fix the problem: