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.

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top