-
- LoadModule rewrite_module libexec/mod_rewrite.so
- AddModule mod_rewrite.c
2.x 的使用者請檢查conf/httpd.conf 中是否存在以下一段程式碼:
LoadModule rewrite_module modules/mod_rewrite.so
複製程式碼
如果存在,>
注意,如果網站使用透過虛擬主機來定義,請務必加到虛擬主機配置,即 中去,如果加在虛擬主機配置外部將可能無法使用。
改好後,將 Apache 重新啟動。
Apache conf檔案設定(參考http://download.destoon.com/rewrite/apache.txt)規則:
-
-
-
-
- # Destoon B2B Rewrite Rules
- ErrorDocument 404 /404.php
- RewriteEngine OnRewriteRule ^(.*)/file/(.*).php(. *)$ /404.php
- RewriteRule ^(.*)-htm-(.*)$ $1.php?$2
- RewriteRule ^(.*)/show-([0-9] )([ -])?([0-9] )?.html$ $1/show.php?itemid=$2&page=$4
- RewriteRule ^(.*)/list-([0-9] )([-] )?([0-9] )?.html$ $1/list.php?catid=$2&page=$4
- RewriteRule ^(.*)/show/([0-9] )/([0-9 ] )?([/])?$ $1/show.php?itemid=$2&page=$3
- RewriteRule ^(.*)/list/([0-9] )/([0-9] )? ([/])?$ $1/list.php?catid=$2&page=$3
- RewriteRule ^(.*)/([A-za-z0-9_-] )-c([0-9] ) -([0-9] ).html$ $1/list.php?catid=$3&page=$4
- RewriteRule ^(.*)/([a-z] )/(.*).shtml$ $1/$2/ index.php?rewrite=$3
- RewriteRule ^(.*)/com/([a-z0-9_-] )/([a-z] )/(.*).html$ $1/index.php?homepage =$2&file=$3&rewrite=$4
- RewriteRule ^(.*)/com/([a-z0-9_-] )/([a-z] )([/])?$ $1/index.php?homepage =$2&file=$3
RewriteRule ^(.*)/com/([a-z0-9_-] )([/])?$ $1/index.php?homepage=$2
複製程式碼
3、Nginx法則(參考http://download.destoon.com/rewrite/nginx.txt):
-
-
- rewrite ^/(.*).(asp|aspx|asa|asax|dll|jsp|cgi|fcgi|pl)(.*)$ /404.php last;
- rewrite ^/(.*)/file/(.*).php(.*)$ /404.php last;
- rewrite ^/(.*)-htm-( .*)$ /$1.php?$2 last;
- rewrite ^/(.*)/show-([0-9] )([-])?([0-9] )?.html$ / $1/show.php?itemid=$2&page=$4 last;
- rewrite ^/(.*)/list-([0-9] )([-])?([0-9] )?.html $ /$1/list.php?catid=$2&page=$4 last;
- rewrite ^/(.*)/show/([0-9] )/([0-9] )?([/]) ?$ /$1/show.php?itemid=$2&page=$3 last;
- rewrite ^/(.*)/list/([0-9] )/([0-9] )?([/] )?$ /$1/list.php?catid=$2&page=$3 last;
- rewrite ^/(.*)/([A-za-z0-9_-] )-c([0-9] ) -([0-9] ).html$ /$1/list.php?catid=$3&page=$4 last;
- rewrite ^(.*)/([a-z] )/(.*).shtml$ $1 /$2/index.php?rewrite=$3 last;
- rewrite ^/(com)/([a-z0-9_-] )/([a-z] )/(.*).html$ /index.php ?homepage=$2&file=$3&rewrite=$4 last;
- rewrite ^/(com)/([a-z0-9_-] )/([a-z] )([/])?$ /index.php? homepage=$2&file=$3 last;
rewrite ^/(com)/([a-z0-9_-] )([/])?$ /index.php?homepage=$2 last;
複製程式碼
4、Zeus規則(參考http://download.destoon.com/rewrite/zeus.txt):
-
- 將URL 與$ 配對^(.*).(asp|aspx|asa|asax|dll|jsp|cgi|fcgi|pl)(. *)$
- 如果符合則
- 設定URL = /404.php
- endif
- 將URL 與$ 符合^(.*)/file/(.*).php(.*)$
- 如果符合則
- 設定URL = /404.php
- endif
- 將URL 與^(.*)-htm-(.*)$ 配對到$
- 如果符合則
- 設定URL = $1.php?$2
- endif
- 將URL 與$ 匹配^(.*)/show-([0-9] )([-])?([0-9] )? 。 html$
- 如果符合則
- 設定URL = $1/show.php?itemid=$2&page=$4
- endif
- 將URL 與$ 匹配^(.*)/list-([0- 9] )([-])?([0-9] )?.html$
- 如果符合則
- set URL = $1/list.php?catid=$2&page=$4
- endif
- 將URL 與$ 符合^(.*)/show/([0-9] )/([0-9] )?([/])?$
- 如果符合則
- 設定URL = $1 /show.php?itemid=$2&page=$3
- endif
- 將URL 與$ 匹配^(.*)/list/([0-9] )/([0-9] )?([/ ])?$
- 如果符合則
- 設定URL = $1/list.php?catid=$2&page=$3
- endif
- 將URL 與$ 配對^(.*)/([A- za-z0-9_-] )-c([0-9] )-([0-9] ).html$
- 如果符合則
- 設定URL = $1/list.php?catid=$3&page =$4
- endif
- 將URL 與$ 匹配^(.*)/([a-z] )/(.*).shtml$
- 如果符合則
- 設定URL = $1/$2/index .php?rewrite=$3
- endif
- 將URL 與$ 配對^(.*)/com/([a-z0-9_-] )/([a-z] )/(.*).html$
- 如果符合則
- 設定URL = $1/index.php?homepage=$2&file=$3&rewrite=$4
- endif
- 將URL 與$ 相符^(.*)/com/([a -z0-9_-] )/([a-z] )([/])?$
- 如果符合則
- 設定URL = $1/index.php?homepage=$2&file=$3
- endif
- 將URL 與$ 匹配^(.*)/com/([a-z0-9_-] )([/])?$
- 如果符合則
- 設定URL = $1/index.php?homepage =$2
- endif
複製碼
5、IIS6伺服器
請下載 http://download.destoon.com/rewrite/IIS_Rewrite.zip
規則已經設定好,請按readme.txt檔案內容進行操作
如果網站支援httpd.ini文件,請使用以下規則(參考http://download.destoon.com/rewrite/httpd.ini):
-
-
[ISAPI_Rewrite]
- # Destoon B2B www.destoon.com
- # 3600 = 1 小時3600
RepeatLimit 32
# 保護httpd.ini 和httpd.parse.errors 檔案
- # 不透過HTTP 存取
- RewriteRule ^(.*).(asp|aspx|asa|asax|dll|jsp|cgi|fcgi|pl)(.*)$ /404.php
- 重寫規則^(.*)/file/(. *) .php(.*)$ /404.php
- RewriteRule ^(.*)-htm-(.*)$ $1.php?$2
- RewriteRule ^(.*)/show-([0 -9 ] )([-])?([0-9] )?.html$ $1/show.php?itemid=$2&page=$4
- RewriteRule ^(.*)/list-([0-9 ] ) ([-])?([0-9] )?.html$ $1/list.php?catid=$2&page=$4
- RewriteRule ^(.*)/show/([0-9] ) /( [0-9] )?([/])?$ $1/show.php?itemid=$2&page=$3
- RewriteRule ^(.*)/list/([0-9] )/([ 0- 9] )?([/])?$ $1/list.php?catid=$2&page=$3
- RewriteRule ^(.*)/([A-za-z0-9_-] )-c( [0 -9] )-([0-9] ).html$ $1/list.php?catid=$3&page=$4
- RewriteRule ^(.*)/com/([a-z0-9_-] )/ ([a-z] )/(.*).html$ $1/index.php?homepage=$2&file=$3&rewrite=$4
- RewriteRule ^(.*)/com/([a-z0-9_- ] ) /([a-z] )([/])?$ $1/index.php?homepage=$2&file=$3
- RewriteRule ^(.*)/com/([a-z0-9_-] )( [/ ])?$ $1/index.php?homepage=$2
- RewriteRule ^(.*)/([a-z] )/(.*).shtml$ $1/$2/index.php?rewrite=$3
-
-
複製程式碼 6、IIS7伺服器
規則(參考http://download.destoon.com/rewrite/web.config.txt)為:
重寫生效後,請在網站後面然後》網站設定=》SEO優化=》網址重寫,選擇「開啟」提交。
然後進入各模組的模組設定「SEO設定」選擇對應偽靜態位址規則,選擇「更新位址」提交即可。
以上透過實例介紹了destoon URL Rewrite(偽靜態)的設定方法,希望對大家有幫助。
推薦閱讀:destoon入門教學與技巧實例
|