views:

66

answers:

1

Part One

I want to .htaccess redirect all HTML files to the home page. I looked at this guy's question (http://bit.ly/3l9K86), and wrote this code:

RewriteCond %{HTTP_HOST} ^pandamonia.us$ [OR]  
RewriteCond %{HTTP_HOST} ^www.pandamonia.us$  
RewriteRule .*\.html$ "http\:\/\/pandamonia\.us\/" [L]

but the problem is that it also redirects the homepage to itself, causing the universe to end. So my question, is how can I redirect every HTML page that is not the homepage to the homepage.

 

Part Two

http://stackoverflow.com/questions/1732275/exclude-certain-subfolders-and-domains-in-redirects

+3  A: 

Try changing .* to .+ in the regexp, that should mean 'at least one character' instead of zero or more characters, so the empty string should be avoided.

Wait. The initial '/' is included. Try it like:

RewriteRule /.+\.html$ "http\:\/\/pandamonia\.us\/" [L]
Rasmus Kaj
How did you get it to syntax highlight the code?
Alexsander Akers
I just put for spaces before the code line and stackoverflow did the rest. :-)
Rasmus Kaj
Can you take a look at part two? :)
Alexsander Akers