简体   繁体   English

htaccess从index.php重定向到非索引

[英]Htaccess redirect from index.php to non-index

I want to make a redirect to my htaccess with the follow: 我想通过以下方式重定向到我的htaccess:

http://example.com/index.php -> http://example.com
http://example.com/index.php/controller -> http://example.com/controller
http://example.com/index.php/controller/any-method -> http://example.com/controller/any-method

In 2 words, i want to detect if the URL contains index.php and redirect it to a url without it but to keep other segments after the index.php 用两个词,我想检测URL是否包含index.php并将其重定向到没有URL的URL,但保留index.php之后的其他段

Thank you in advance. 先感谢您。

This worked for me: 这为我工作:

RewriteCond %{REQUEST_URI} ^/index.php/
RewriteRule ^index.php/(.*) /$1 [R,L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM