美文网首页
TP5路由隐藏index.php

TP5路由隐藏index.php

作者: 铁匠简记 | 来源:发表于2018-05-07 11:53 被阅读449次

官方默认的.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>

如果用phpstudy,规则如下:

1、确认你的apache开启rewrite模块、

2、修改官方文件最后一行 (PHP5.5+)

RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]

如果你使用的apache版本使用上边的方式无法正常隐藏index.php 可以尝试使用下边的方式配置.htaccess文件:

1、确认你的apache开启rewrite模块、

2、修改官方文件最后一行,在/$1前边加一个 ? (注意英文格式半角)

 RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L]

如果是Nginx环境,可以在Nginx.conf中添加:

location / { //......省略部分代码
    if(!-e $request_filename){
        rewrite ^(.*)$ /index.php?s=$1 last;
        break;
    }
}

相关文章

网友评论

      本文标题:TP5路由隐藏index.php

      本文链接:https://www.haomeiwen.com/subject/vppmrftx.html