Welcome to WebmasterWorld Guest from 126.96.36.199
I have placed the following into my .htaccess file:
RewriteRule ^fake\.html$ index.html [L]
It works fine on my local machine, but fails to work on the remote server.
I thought it was that mod_rewrite wasnt there, but phpinfo.php sugguests that mod_rewrite is one of the 'Loaded Modules'.
I am now a bit lost as to whose fault it is.
a) My .htaccess file and my understanding is incorrect
b) The server hasnt got mod_rewrite setup right
d) neither - something else
Thanks in advance
That should have worked. If you requested fake.html, your server should have responded with the contents of index.html in the same subdirectory. You might try it as an absolute path (with a slash) as shown.
RewriteRule ^fake\.html$ /index.html [L]
Do you have access to a raw access or error log? Very often, these will point you to the problem. Often, you will see that the server path is different from the url path, and then you can use RewriteBase to correct misdirected requests. For example, you may need to add something like:
Ref: Introduction to mod_rewrite [webmasterworld.com]
If you have more detailed information about this, please post.
RewriteEngine is a supported directive in per-directory .htaccess context in Apache 1.3 and Apache 2.0 as stated in the Apache documentation, and it seems to work well on my sites - at least as long as Options FollowSymLinks are enabled as necessary.
I've surrounded "suspect" mod_rewrite code blocks with RewriteEngine off and RewriteEngine on directives to "turn off" the code blocks temporarily to see if a problem goes away. It works for me.
I'm therefore rather confused by your post. :o
I'm wondering if another rewrite (possibly at the httpd.conf level) is preempting the intended rewrite such that a 403-Forbidden is the result. It's a stumper.
Note that, by default, rewrite configurations are not inherited. This means that you need to have a RewriteEngine on directive for each virtual host in which you wish to use it.
That said, RewriteEngine On can have effect in .htaccess, but only if it's in VirtualHost or server config already.
i'm reading that as meaning that if you have some mod_rewrite rules in the main site configuration that they will not be inherited by the virtual hosts you may define... that you have to specifically set them in the virtual hosts via one of the allowed means (conf file or .htaccess or blah)...
in my experiance, the only thing related to mod_rewrite that i had to have in the master config was the module loading commands... after that and with proper OPTIONS, each site, master and virtuals, are on their own...
As to your reading of this - sure, that's what happens in practice, but I don't see how this can follow from this passage which tells about RewriteEngine ;)