htaccess redirect everything except index page

2020-07-23 03:18发布

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]

2条回答
相关推荐>>
2楼-- · 2020-07-23 04:06

Try:

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 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.

查看更多
forever°为你锁心
3楼-- · 2020-07-23 04:11

Try adding the

Options +FollowSymLinks -MultiViews -Indexes

at the very top and give it a try.

查看更多
登录 后发表回答