Pergunta

I have a condition for url redirect like,

www.domain.com/something/anotherthing/index.php

i need the above url to redirect to

www.domain.com/something/anotherthing/

If i go to

www.domain.com/index.php/something/anotherthing

i want to redirect to

www.domain.com/something/anotherthing

i have a redirect htaccess rule for this

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/index.php$1 [NC]

RewriteRule ^ /%1$1 [R=301,L]

But this works for the first condition but in the later it redirect me to the root page. Can anyone please help in this redirection.

Thanks in Advance.

Foi útil?

Solução

Try something like this:

RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/index.php/?([^\ \?]*) [NC]
RewriteRule ^ %1/%2 [R=301,L]

That should handle any location of /index.php.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top