apache(.htaccess)、nginx的URL重新--隐藏index.php

官方默认的.htaccess文件

<IFModule mod_rewrite.c>

Options+FollowSymlink-Multiviews

RewriteEngine On

RewirteCond %{REQUEST_FILENAME} !-d

RewirteCond %{REQUEST_FILENAME} !-f

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

</IFModule>


如果用的phpstudy,规则如下:

<IFModule mod_rewrite.c>

Options+FollowSymlink-Multiviews

RewriteEngine On

RewirteCond %{REQUEST_FILENAME} !-d

RewirteCond %{REQUEST_FILENAME} !-f

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

</IFModule>


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

location / {

    if(!-e $request_filename){

        rewrite ^(.*)$ /index.php?s=/$1 last;

        break;

    }

}

猜你喜欢

转载自blog.csdn.net/fanblog/article/details/79631220