眾所周知,動態頁面不利於收錄和排名。偽靜態可以完美的解決這問題,配合百度雲加速CDN,可以讓動態頁面有靜態頁面一樣快的訪問速度。
今天開拓族給大家帶來帝國CMS偽靜態的詳細設置方法。
1.欄目設置為動態訪問
修改單個欄目屬性,如下圖
批量修改欄目屬性,如下圖:
2.首頁也設置為動態訪問
現在全站都是動態訪問了。
3.偽靜態參數設置
如上圖,設置好偽靜態參數。如果不會設置,點擊默認按鈕,使用帝國默認的偽靜態規則。
4.更新信息頁地址
設置好后,網站的超鏈接都變成偽靜態了,但打開網頁卻顯示404。這是因為網站服務器還未配置偽靜態規則。
5.給網站服務器設置偽靜態規則
Nginx偽靜態規則:
location / { rewrite ^([^\.]*)/listinfo-([0-9]+)-([0-9]+)\.html$ $1/e/action/ListInfo/index.php?classid=$2&page=$3 last; rewrite ^([^\.]*)/showinfo-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/e/action/ShowInfo.php?classid=$2&id=$3&page=$4 last; rewrite ^([^\.]*)/infotype-([0-9]+)-([0-9]+)\.html$ $1/e/action/InfoType/index.php?ttid=$2&page=$3 last; rewrite ^([^\.]*)/tags-(.+?)-([0-9]+)\.html$ $1/e/tags/index.php?tagname=$2&page=$3 last; if (!-e $request_filename) { return 404; } }
修改完配置文件,需要重啟nginx生效。
Apache偽靜態規則
RewriteEngine On ErrorDocument 404 /404.html Rewritebase / #信息列表 RewriteCond %{QUERY_STRING} ^(.*)$ RewriteRule ^listinfo-(.+?)-(.+?)\.html$ /e/action/ListInfo/index\.php\?classid=$1&page=$2 #信息內容頁 RewriteCond %{QUERY_STRING} ^(.*)$ RewriteRule ^showinfo-(.+?)-(.+?)-(.+?)\.html$ /e/action/ShowInfo\.php\?classid=$1&id=$2&page=$3 #標題分類列表頁 RewriteCond %{QUERY_STRING} ^(.*)$ RewriteRule ^infotype-(.+?)-(.+?)\.html$ /e/action/InfoType/index\.php\?ttid=$1&page=$2 #TAGS信息列表頁 RewriteCond %{QUERY_STRING} ^(.*)$ RewriteRule ^tags-(.+?)-(.+?)\.html$ /e/tags/index\.php\?tagname=$1&page=$2 #評論列表頁 RewriteCond %{QUERY_STRING} ^(.*)$ RewriteRule ^comment-(.+?)-(.+?)-(.+?)-(.+?)-(.+?)-(.+?)\.html$ /e/pl/index\.php\?doaction=$1&classid=$2&id=$3&page=$4&myorder=$5&tempid=$6
至此,帝國CMS偽靜態教程圓滿結束,更多織夢模板請看開拓族。