This is giving me a 500 internal server error. Any suggestions? I have tried various examples but I think I'm missing something...

RewriteEngine On
RewriteCond  %{request_uri}!^ /index\.htm
RewriteRule  ^(.*) /index\.htm [R=permanent,L]

It displays the homepage if I navigate there but anything that meets the conditions (all appart from index.htm gives the server 500)

EDIT: with the above code it now doesnt give any 500 errors but it doesnt redirect for any pages

link|improve this question
feedback

migrated from stackoverflow.com Apr 9 '10 at 13:55

This question came from our site for professional and enthusiast programmers.

2 Answers

You're not redirecting to /index.htm, you're redirecting to / which is different as far as Apache is concerned.

Try: RewriteRule ^(.*)$ /index.htm [R=permanent,L]

link|improve this answer
please can you edit out the domain - i forgot :) – SocialAddict Apr 9 '10 at 10:40
Incidently I tried that just before your post with the same issue :( – SocialAddict Apr 9 '10 at 10:40
I'm using utf-8 as the .htaccess file type is that correct? – SocialAddict Apr 9 '10 at 10:41
still doesn't redirect but displays the original (old) page – SocialAddict Apr 9 '10 at 11:35
What about capitalising REQUEST_URI? It might be case-sensitive, and in all the Apache documentation, those macros ARE IN CAPS (not shouting, just illustrating :-P ) – Andy Shellam Apr 9 '10 at 11:50
show 1 more comment
feedback

Your rewrite condition isn't split up well and your Not-StartWith is part of the previous parameter. :) You need a space after the %{REQUEST_URL} and before the !^

RewriteEngine On
RewriteCond  %{REQUEST_URI} !^/index\.htm$
RewriteRule  ^(.*) /index.htm [R=permanent,L]
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.