IIS版本
低版本的服务器环境支持ISAPI_Rewrite的话,可以配置httpd.ini文件
内容如下: RewriteRule (.*)$ /index\.php\?s=$1 [I]
高版本的可配置
<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>
nginx低版本不支持path_info可以用
location / { if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=$1 last; break; } }
apache需要开启rewrite,然后在根目录建立.htaccess文件
内容如下
<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] </IfModule>