一、Apache的伪静态设置
1、网站根目录下须要有 .htaccess 文件,没有则本身建立一个,内容为
<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] </IfModule>
如果你的apache是fastcgi形式下,则须要修正
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] 替换成 RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]
2、在apache的设置文件httpd.conf中查找 : LoadModule rewrite_module modules/mod_rewrite.so 将前面的#去掉,如果没有这段内容,则须要手动加上
3、在apache的设置文件httpd.conf中查找一切的 AllowOverride None,将 None 都替换成 All . 保留文件 并重启apache效劳。
二、Nginx的伪静态设置
找到nginx的设置文件 nginx.conf, 在里面的 server{ } 里增添以下内容
location / { if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=$1 last; break; } }
重启nginx即可见效
三、IIS的伪静态设置
如果你的效劳器环境支撑ISAPI_Rewrite的话,能够设置httpd.ini文件,增加下面的内容:
RewriteRule (.*)$ /index\.php\?s=$1 [I]
在IIS的高版本下面能够设置web.Config,在中心增加rewrite节点:
<rewrite> <rules> <rule name="OrgPage" stopProcessing="true"> <match url="^(.*)$" /> <conditions logicalGrouping="MatchAll"> <add input="{HTTP_HOST}" pattern="^(.*)$" /> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> </conditions> <action type="Rewrite" url="index.php/{R:1}" /> </rule> </rules> </rewrite>
以上就是PHP各环境下的伪静态设置的要领引见(代码)的细致内容,更多请关注ki4网别的相干文章!