隐藏index.php

Apache :

                 #如果mode_rewrite.c模块存在,则执行以下命令
 Options +FollowSymlinks -Multiviews
 RewriteEngine On                           #开启rewriteEngine
 
 RewriteCond %{REQUEST_FILENAME} !-d         #!-d 不是目录或目录不存在
 RewriteCond %{REQUEST_FILENAME} !-f          #! -f 不是文件或文件不存在
 
 #转给index.php处理 #这是最后一个匹配项,不在往下匹配
 RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]

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

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

phpstudy :

Options +FollowSymlinks -Multiviews RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]

Nginx.conf:

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

posted @ 2020-08-04 11:42  琴似蓝调  阅读(381)  评论(0编辑  收藏  举报