tp5.1 nginx环境下url去掉index.php

Posted 大尹

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了tp5.1 nginx环境下url去掉index.php相关的知识,希望对你有一定的参考价值。

原来的地址http://xxxxxxx/index.php/admin/login/index.html

修改完的路径http://xxxxxxx/admin/login/index.html

修改.htaccess文件

<IfModule mod_rewrite.c>
  Options +FollowSymlinks -Multiviews
  RewriteEngine On
 
 
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L]
</IfModule>

添加nginx配置,如果使用的宝塔linux,直接在网址->单个网站设置->配置文件中合适的地方加上下面的代码即可

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

 

以上是关于tp5.1 nginx环境下url去掉index.php的主要内容,如果未能解决你的问题,请参考以下文章