pbootcms偽靜態(tài)配置教程,針對IIS7環(huán)境、Apache環(huán)境、Nginx環(huán)境不同的配置方案,配置程序偽靜態(tài)后URL中將不再包含index.php,整個地址更美觀。
1、IIS7+環(huán)境(IIS6的環(huán)境自行百度):
1)安裝rewrite組件,如果使用虛擬空間一般空間商默認已經安裝;
2)到網站后臺配置參數(shù)中開啟偽靜態(tài)開關;
3)在站點目錄建立web.config文件(可到源碼包rewrite目錄下拷貝規(guī)則),規(guī)則內容如下:
#Pbootcms 2.X+版本使用如下規(guī)則: <?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="reIndex" stopProcessing="true"> <match url="^(.*)$" ignoreCase="true" /> <conditions logicalGrouping="MatchAll"> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> </conditions> <action type="Rewrite" url="index.php?p={R:1}" appendQueryString="true" /> </rule> </rules> </rewrite> </system.webServer> </configuration> |
2、Apache環(huán)境
1)開啟Apache重寫模塊,具體請百度,如果使用虛擬空間一般空間商默認已經開啟;
2)到網站后臺配置參數(shù)中開啟偽靜態(tài)開關;
3)在站點目錄建立.htaccess文件(可到源碼包rewrite目錄下拷貝規(guī)則),規(guī)則內容如下:
#Pbootcms 2.X+版本使用如下規(guī)則: <IfModule mod_rewrite.c> Options +FollowSymlinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?p=$1 [QSA,PT,L] </IfModule> |
3、Nginx環(huán)境
1、到網站后臺配置參數(shù)中開啟偽靜態(tài);
2、在nginx主機配置中添加偽靜態(tài)規(guī)則,規(guī)則如下:
#Pbootcms 2.X+版本使用如下規(guī)則: location / { if (!-e $request_filename){ rewrite ^/(.*)$ /index.php?p=$1 last; } } |
注意:Nginx中如果站點部署在二級目錄,請對應修改重寫規(guī)則, 代碼如下:
#Pbootcms 2.X+版本使用如下規(guī)則: location / { if (!-e $request_filename){ rewrite ^/(.)$/二級目錄/index.php/$1 last; } } |
4、阿里云增強版Nginx虛擬主機
#Pbootcms 2.X+版本使用如下規(guī)則 阿里云增強版: location / { if (!-e $request_filename){ rewrite ^(.*)$ /index.php?s=$1 last; break; } } |
工具:
偽靜態(tài)轉換工具:https://www.bt.cn/Tools https://www.onexin.net/rewrite.php