I have a strange problem. Here are two examples of a URL rewrite in my htaccess file. The first one doesn't work and returns the variable for "query" as null in the PHP file.
RewriteRule ^search/([A-Za-z0-9-\s]+)$ search.php?query=$1
The second one (that I have used as a test) works perfectly fine.
RewriteRule ^foo/([A-Za-z0-9-\s]+)$ search.php?query=$1
I have found that the problem is that the beginning of the pattern cannot be the same as the name of the php file I'm using with it. This has always worked for me, and I am only now encountering this problem as I have moved to a new server.
Is there some kind of setting that is causing this?
You need to place this line on top of your .htaccess to turn off
MultiViews
option:Option
MultiViews
is used byApache's content negotiation module
that runs beforemod_rewrite
and makes Apache server match extensions of files. So/file
can be in URL but it will serve/file.php
.