htaccess重定向除索引页面以外的所有内容 [英] htaccess redirect everything except index page
本文介绍了htaccess重定向除索引页面以外的所有内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经从我的域中删除了博客,而是放置了一个简单的index.html。
如何重定向所有传入流量,以使其不显示404错误,但重定向到索引?
I have removed the blog from my domain and put a simple index.html instead. How do I redirect all the incoming traffic so that it does not show a 404 error, but redirects to the index?
我尝试了此方法,但循环了...
I tried this, but it loops...
RewriteEngine on
RewriteRule ^(.*)$ /index.html [L,R=301]
推荐答案
尝试:
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/index.html
RewriteRule ^(.*)$ /index.html [L,R=301]
正如您提到的那样,我会尝试:
As you mentioned that this doesn't work, I'd try:
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/aaa.html
RewriteRule ^(.*)$ /aaa.html [L,R=301]
index.html是常规默认文件名,因此可能存在服务器级别的规则,而不是您的.htaccess中的规则。不过,这取决于服务器的设置。
index.html is a general default file name, so there might be rules that are on the server level, not in your .htaccess. That depends on the server setup, though.
这篇关于htaccess重定向除索引页面以外的所有内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文