Forum Moderators: phranque
/directory/file-name.html
and a mod_rewrite mapping:
/directory/file-name/ to /directory/file-name.html
That's all fine until the next rule which maps:
/directory/file-name/var1-var2/ to /directory/another-file.html?var1=var1&var2=var2
The problem is that on the server (not locally) this is being processed as a request for:
/directory/file-name.html
with the parameter:
"/var1-var2/"
As far as I can see, mod_rewrite isn't getting a look-in.
Anyone know a way to stop this?
Nothing 'unusual' has been done with the config - just turned on a few PHP options and set up some Aliases. Otherwise it's vanila-Apache. I control the server.
The same behaviour occurs on another Debian server: Apache/1.3.29 (Debian GNU/Linux).
My development platform (Darwin) behaves differently, as have other servers I've worked on.
RewriteRule ^directory/([-a-z]+)/?$ /directory/$1.html
RewriteRule ^directory/[-a-z/]+/photo.jpg /directory/photo.jpg
As I said, mod_rewrite is being ignored, and the '/directory/file-name.html' file being executed with everything after 'file-name' appearing in $_SERVER["PATH_INFO"]...
It's a common problem, because people just assume they should add new stuff at the end of the LoadModule list, and then mod_rewrite, mod_auth, and a whole bunch of other stuff stops working for php files. Load php first, and then mod_rewrite can execute.
Apache 2.0 resolves this by letting modules declare their own priority, independent of the LoadModule order.
Adding php or any other non-Apache module makes your Apache installation non-plain-vanilla -- just adds a touch of flavor... ;)
Jim
I've changed the order on the Debian server to put the rewrite_module last, and re-started Apache but the problem persists...
Something in Apache is allowing /filename to be recognised as a file request, wheras on other machines /filename.html is required, and /filename returns a 404. I just can't work out where that option is.
For anyone who's interested, the information is here:
[httpd.apache.org...]
(under "Note on hyperlinks and naming conventions")