So I'm trying to get mod_rewrite working on my new site. I've used mod_rewrite successfully a few years ago, but this time not a single command after 'RewriteEngine On' works.
I'm getting exactly the same effect on my local Apache 2.2 as I do on my web host's server, so it's not that the server isn't configured for mod_rewrite. My local machine runs Windows, and the remote server is Linux, so they're pretty independent systems. Here's what I've checked so far for my localhost:
- The 'LoadModule rewrite_module' line in httpd.conf is not commented with a #
- I have 'Options Indexes FollowSymLinks Includes' in place in my httpd.conf for my html directory
- And I have 'AllowOverride All' in place beside the Options line too.
- The .htaccess file I have in my site's root directory is being accessed. Putting nonsense in the first line gets me an Internal Server Error, removing it takes it away
- Putting 'RewriteEngine Cheese' as the first line gets me a line in my error.log that says 'RewriteEngine must be On or Off', so it definitely seems to be ready to do some rewriting...
BUT. Nothing I type after RewriteEngine On has any effect! I can write nonsense in there and get no error message. I've put lots of commands in there as a test, but even this .htaccess file does nothing:
RewriteEngine On
RewriteRule ^.*$ test.html [R]
That should rewrite every page I go to to be test.html shouldn't it? And yet, nothing happens at all - if I go to hello.html, I just get a web page saying that hello.html isn't found.
Please can someone offer a suggestion as to what to try next?
Answer
Linux config files, including Apache config files require the last line to be empty. Everything after the last newline will be ignored.
No comments:
Post a Comment