문제

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