i have a rewrite rule in my .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^vt$ vt.php [L]
</IfModule>
if file 'vt' exists in my website directory, the rewrite is done well. but if file 'vt' doesn't exist, apache2 just gives a 404 error.
so it seems apache2 do rewrite after it checks file stat. How do I fix this?
I think this is a bug. I use this rule finnally to avoid use two files (vt and vt.php).
RewriteRule ^vt$ - [H=application/x-httpd-php]
This sounds like there may be 2 things happening here.
Multiviews is making it appear as if mod_rewrite is loadedWhat Multiviews does, is part of mod_negotiation which tries to "guess" what the request is for if it is missing things like an extension. So with Multiviews turned on, if it sees a request for /vt and the file vt doesn't exist, it guesses and finds /vt.php and serves that, otherwise it doesn't nothing and returns a 404. This would make it appear as if the mod_rewrite rule is actually being applied. If mod_rewrite is actually turned on, then it would apply the rule even if mod_negotiation was turned on and the file was missing (which would result in a 404).
So 1. make sure that mod_rewrite is actually loaded. To do this, check your httpd.conf file and there should be a line that looks like this (uncommented):
LoadModule rewrite_module modules/mod_rewrite.so
Or you can try removing the <IfModule mod_rewrite.c> container, if you get a 500 server error, mod_rewrite isn't loaded.
Then 2. add this line in your htaccess file to turn off Multiviews:
Options -Multiviews
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With