扫码关注官方订阅号
thinkphp 如何实现 "http://localhost/index.php?/模块/操作&quo... 变为 "http://localhost/模块/操作" 我想把URL改成这种形式,看起来会比较舒服,但是不知道怎么实现。 是在conifg里面加参数,还是在nginx里面用rewrite?
欢迎选择我的课程,让我们一起见证您的进步~~
用 rewrite 的方式。 官方文档: 隐藏index.php
这个需要在nginx的配置里头rewrite。
原来的格式可以保证在服务器(apache/nginx等)没有rewrite模块的情况下,框架也能正常运行。
rewrite可以类似于:
location /your_app/ { if (!-f $request_filename) { #如果请求到css等资源则略过 rewrite ^/your_app/(.*)$ /your_app/index.php?$1; } }
开启路由匹配,然后再apache里开启rewrite模式
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
用 rewrite 的方式。
官方文档: 隐藏index.php
这个需要在nginx的配置里头rewrite。
原来的格式可以保证在服务器(apache/nginx等)没有rewrite模块的情况下,框架也能正常运行。
rewrite可以类似于:
location /your_app/ { if (!-f $request_filename) { #如果请求到css等资源则略过 rewrite ^/your_app/(.*)$ /your_app/index.php?$1; } }开启路由匹配,然后再apache里开启rewrite模式