开发者

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.

Redirect only HTML files?

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]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜