> 摘要:YzmCMS偽靜態配置(YzmCMS5.0版本的偽靜態規則與之前版本不同,所以本教程只適用于5.0及以上版本):Apache偽靜態(即YzmCMS自帶的.htaccess文件):
**YzmCMS偽靜態配置(YzmCMS5.0版本的偽靜態規則與之前版本不同,所以本教程只適用于5.0及以上版本):**
## Apache偽靜態(即YzmCMS自帶的.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的以上配置是完全沒問題的,如果你用的是老古董的話,那么你可以嘗試修改YzmCMS配置文件:
“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>
~~~
文件下載:[YzmCMS偽靜態配置下載](http://www.yzmcms.com/uploads/201806/05/180605015119944.zip)