Redirect only HTML files?
Part One
I want to .htaccess redirect all HTML files to the home page. I looked at this guy's question (htaccess redirect all html files开发者_StackOverflow), 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
Exclude certain subfolders and domains in redirects
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]
精彩评论