yii2.0系列三:url美化
"urlManager" => [ "enablePrettyUrl" => true, "showScriptName" => false, "suffix" => "", "rules" => [ "<controller:w+>/<action:w+>"=>"<controller>/<action>", ], ],
当前配置是,在 apache 中配置了虚拟目录 /ad,所以访问链接:
http://47.88.190.46/ad/index.php/test/test
会被重定向到 controller/TestController 中的 actionTest;由于虚拟目录的关系, index.php 没有被隐藏,可以通过在根目录下 rewrite 把所有未找到的文件重定向到 /ad/index.php 来解决,但是这样破坏了 yii 目录的独立性,所以还是保留了 index.php; "urlManager" => [ "enablePrettyUrl" => true, "showScriptName" => false, "suffix" => "", "rules" => [ "<controller:w+>/<action:w+>"=>"<controller>/<action>", ], ],
当前配置是,在 apache 中配置了虚拟目录 /ad,所以访问链接:
http://47.88.190.46/ad/index.php/test/test
要隐藏 index.php ,只需要在 .htaccess 文件中添加 RewriteBase /ad 即可
声明:该文观点仅代表作者本人,入门客AI创业平台信息发布平台仅提供信息存储空间服务,如有疑问请联系rumenke@qq.com。
- 上一篇:没有了
- 下一篇:没有了
