美文网首页
apache/nginx隐藏index.php

apache/nginx隐藏index.php

作者: 任人渐疏_Must | 来源:发表于2020-03-30 17:48 被阅读0次

nginx

在vhost.conf中,添加

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

apache

下面是Apache的配置过程,可以参考下:
1、httpd.conf配置文件中加载了mod_rewrite.so模块
2、AllowOverride NoneNone改为 All
3、在应用入口文件同级目录添加.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>

说明:TP5官网教程中在.htaccess中的index.php后面没有?,需加上才能正常使用

相关文章

网友评论

      本文标题:apache/nginx隐藏index.php

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