apache和Nginx隐藏index.php的配置

apache

1
2
3
4
5
6
<IfModule mod\_rewrite.c> 
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST\_FILENAME} !-d
RewriteCond %{REQUEST\_FILENAME} !-f RewriteRule ^(.*)$ index.php \[L,E=PATH\_INFO:$1\]
</IfModule>  

nginx

1
2
3
4
5
6
7
8
9
10
location / { 

if (!-e $request_filename) {

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

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

}
}