根据服务器环境自行配置伪静态规则:
Apache伪静态(即系统自带的.htaccess文件):
<IfModule mod_rewrite.c> Options +FollowSymlinks -Multiviews RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?s=$1 [QSA,PT,L] </IfModule>
Nginx伪静态:
location / { #//...省略部分代码 if (!-e $request_filename){ rewrite ^(.*)$ /index.php?s=$1 last; break; } }
如果你的应用安装在二级目录,Nginx的伪静态方法设置如下,其中youdomain是所在的目录名称。
location /youdomain/ { if (!-e $request_filename){ rewrite ^/youdomain/(.*)$ /youdomain/index.php?s=$1 last; } }
举个栗子:
如果你用的是本机电脑上的phpstudy环境的话,打开配置文件( nginx/conf/vhost.conf ):
location / { index index.html index.htm index.php; #autoindex on; if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=$1 last; break; } }
90%的情况下,Nginx的以上配置是完全没问题的,如果你用的是老古董的话,那么你可以尝试修改配置文件:
“common/config/config.php”,修改 配置项 “set_pathinfo” 为 true 来实现!
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?s={R:1}" /> </rule> </rules> </rewrite>
文件下载:
发表评论