域名访问省略index.php

[ Apache ]

httpd.conf配置文件中加载了mod_rewrite.so模块
AllowOverride None 将None改为 All
把下面的内容保存为.htaccess文件放到应用入口文件的同级目录下

RewriteEngine on
 
RewriteCond $1 !^(index.php|images|robots.txt)
 
RewriteRule ^(.*)$ /index.php?/$1 [L]

[ Nginx ]
在Nginx低版本中,是不支持PATHINFO的,但是可以通过在Nginx.conf中配置转发规则实现:

location / {
    if (!-e $request_filename) {
        rewrite  ^(.*)$  /index.php?s=/$1  last;
    }
}

在location / {  }中添加上这段代码后,重启nginx服务就可以了。

参考:http://www.thinkphp.cn/topic/63996.html


posted @ 2021-03-17 11:46  流浪2024  阅读(273)  评论(0编辑  收藏  举报