我想要任何请求,如http://example.com/whatever/index.php301进行重定向http://example.com/whatever/.
我尝试添加:
rewrite ^(.*/)index.php$ $1 permanent;
location / {
index index.php;
}
Run Code Online (Sandbox Code Playgroud)
这里的问题是,这个重写在根URL上运行,导致无限重定向循环.
编辑:
我需要一个通用的解决方案
http://example.com/ 应该提供文件 webroot/index.php
http://example.com/index.php,应该301重定向到 http://example.com/
http://example.com/a/index.php 应该301重定向到 http://example.com/a/
http://example.com/a/ 应该服务于index.php脚本 webroot/a/index.php
基本上,我从不想在地址栏中显示"index.php".我有旧的反向链接,我需要重定向到规范的网址.