문제

I've got the following problem:
I need to redirect (301) from /index.php to homepage but there are rewrite rules:

RewriteCond %{REQUEST_URI} (/|\.htm|\.php|\.html|/[^.]*)$  [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php

And there is a loop of redirects when I add line:

Redirect 301 /index.php http://example.com/

How can I do it without changing the rewrite rules? .htaccess is not clear enough for me

도움이 되었습니까?

해결책

Have your rule like this:

RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteRule ^(.*?)index\.php$ /$1 [L,R=301,NC,NE]

RewriteCond %{REQUEST_URI} (\.html?|\.php|/[^.]*)$  [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top