开发者

htaccess redirect everything except index page

开发者 https://www.devze.com 2023-01-25 11:59 出处:网络
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 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]


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.


Try adding the

Options +FollowSymLinks -MultiViews -Indexes

at the very top and give it a try.

0

精彩评论

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