共計 1519 個字符,預計需要花費 4 分鐘才能閱讀完成。
pbootcms 的偽靜態規則,需要去后臺配置參數 -URL 規則下選擇偽靜態模式,保存。PBOOTCMS 網站根目錄下有個 rewrite 文件里有三種偽靜態方式,根據實際情況選擇使用。
偽靜態配置:
標簽作用:配置程序偽靜態后 URL 中將不再包含 index.php,整個地址更美觀
1、IIS7+ 環境 (IIS6 的環境自行百度):
1) 安裝 rewrite 組件,如果使用空間一般空間商默認已經安裝;
2) 到后臺配置參數中開啟偽靜態開關;
3) 在站點目錄建立 web.config 文件 (可到源碼包 rewrite 目錄下拷貝規則),規則內容如下:
#1.X 版本使用如下規則:
#2.X+ 版本使用如下規則:
2、Apache 環境
1) 開啟 Apache 重寫模塊,具體請百度,如果使用空間一般空間商默認已經開啟;
2) 到后臺配置參數中開啟偽靜態開關;
3) 在站點目錄建立.htaccess 文件 (可到源碼包 rewrite 目錄下拷貝規則),規則內容如下:
#1.X 版本使用如下規則:
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
# 如果頁面出現 ”No input file specified.” 請注釋第一條,啟用第二條
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
#RewriteRule ^(.*)$ index.php [E=PATH_INFO:$1,QSA,PT,L]
#2.X+ 版本使用如下規則:
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?p=$1 [QSA,PT,L]
3、Nginx 環境
1、到后臺配置參數中開啟偽靜態;
2、在 nginx 虛擬主機 location 配置中添加規則,規則如下:
#1.X 版本使用如下規則:
location / {
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php/$1 last;
}
}
#2.X+ 版本使用如下規則:
location / {
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php?p=$1 last;
}
}
注意:Nginx 中如果站點部署在二級目錄,請對應修改重寫規則,如:二級目錄為 test 則:rewrite ^/test/(.*)$ /test/index.php?p=$1 last;
附:nginx 開啟 PHP 及 pathinfo 支持的方法,在 server 內部添加如下內容:
location ~ .php(.*)$ {
root D:/wwwroot; #你的網站目錄,注意修改
fastcgi_pass 127.0.0.1:9000; #php-cgi 監聽地址
fastcgi_index index.php; #默認頁
fastcgi_split_path_info ^(.+.php)(.*)$; #分離路徑
fastcgi_param PATH_INFO $fastcgi_path_info; #添加 PATH_INFO 信息
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}