Domanda

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

È stato utile?

Soluzione

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]
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top