开发者

Redirect only HTML files?

开发者 https://www.devze.com 2022-12-10 19:35 出处:网络
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:

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

精彩评论

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

关注公众号