首頁 >後端開發 >php教程 >destoon中URL Rewrite(偽靜態)設定方法教程

destoon中URL Rewrite(偽靜態)設定方法教程

WBOY
WBOY原創
2016-07-25 08:53:121819瀏覽
  1. LoadModule rewrite_module libexec/mod_rewrite.so
  2. AddModule mod_rewrite.c
2.x 的使用者請檢查conf/httpd.conf 中是否存在以下一段程式碼:

LoadModule rewrite_module modules/mod_rewrite.so
  1. 複製程式碼
複製程式碼

如果存在,>

注意,如果網站使用透過虛擬主機來定義,請務必加到虛擬主機配置,即
中去,如果加在虛擬主機配置外部將可能無法使用。 改好後,將 Apache 重新啟動。 Apache conf檔案設定(參考http://download.destoon.com/rewrite/apache.txt)規則:
  1. # Destoon B2B Rewrite Rules
  2. ErrorDocument 404 /404.php
  3. RewriteEngine OnRewriteRule ^(.*)/file/(.*).php(. *)$ /404.php
  4. RewriteRule ^(.*)-htm-(.*)$ $1.php?$2
  5. RewriteRule ^(.*)/show-([0-9] )([ -])?([0-9] )?.html$ $1/show.php?itemid=$2&page=$4
  6. RewriteRule ^(.*)/list-([0-9] )([-] )?([0-9] )?.html$ $1/list.php?catid=$2&page=$4
  7. RewriteRule ^(.*)/show/([0-9] )/([0-9 ] )?([/])?$ $1/show.php?itemid=$2&page=$3
  8. RewriteRule ^(.*)/list/([0-9] )/([0-9] )? ([/])?$ $1/list.php?catid=$2&page=$3
  9. RewriteRule ^(.*)/([A-za-z0-9_-] )-c([0-9] ) -([0-9] ).html$ $1/list.php?catid=$3&page=$4
  10. RewriteRule ^(.*)/([a-z] )/(.*).shtml$ $1/$2/ index.php?rewrite=$3
  11. RewriteRule ^(.*)/com/([a-z0-9_-] )/([a-z] )/(.*).html$ $1/index.php?homepage =$2&file=$3&rewrite=$4
  12. 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):
  1. rewrite ^/(.*).(asp|aspx|asa|asax|dll|jsp|cgi|fcgi|pl)(.*)$ /404.php last;
  2. rewrite ^/(.*)/file/(.*).php(.*)$ /404.php last;
  3. rewrite ^/(.*)-htm-( .*)$ /$1.php?$2 last;
  4. rewrite ^/(.*)/show-([0-9] )([-])?([0-9] )?.html$ / $1/show.php?itemid=$2&page=$4 last;
  5. rewrite ^/(.*)/list-([0-9] )([-])?([0-9] )?.html $ /$1/list.php?catid=$2&page=$4 last;
  6. rewrite ^/(.*)/show/([0-9] )/([0-9] )?([/]) ?$ /$1/show.php?itemid=$2&page=$3 last;
  7. rewrite ^/(.*)/list/([0-9] )/([0-9] )?([/] )?$ /$1/list.php?catid=$2&page=$3 last;
  8. rewrite ^/(.*)/([A-za-z0-9_-] )-c([0-9] ) -([0-9] ).html$ /$1/list.php?catid=$3&page=$4 last;
  9. rewrite ^(.*)/([a-z] )/(.*).shtml$ $1 /$2/index.php?rewrite=$3 last;
  10. rewrite ^/(com)/([a-z0-9_-] )/([a-z] )/(.*).html$ /index.php ?homepage=$2&file=$3&rewrite=$4 last;
  11. 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):

  1. 將URL 與$ 配對^(.*).(asp|aspx|asa|asax|dll|jsp|cgi|fcgi|pl)(. *)$
  2. 如果符合則
  3. 設定URL = /404.php
  4. endif
  5. 將URL 與$ 符合^(.*)/file/(.*).php(.*)$
  6. 如果符合則
  7. 設定URL = /404.php
  8. endif
  9. 將URL 與^(.*)-htm-(.*)$ 配對到$
  10. 如果符合則
  11. 設定URL = $1.php?$2
  12. endif
  13. 將URL 與$ 匹配^(.*)/show-([0-9] )([-])?([0-9] )? 。 html$
  14. 如果符合則
  15. 設定URL = $1/show.php?itemid=$2&page=$4
  16. endif
  17. 將URL 與$ 匹配^(.*)/list-([0- 9] )([-])?([0-9] )?.html$
  18. 如果符合則
  19. set URL = $1/list.php?catid=$2&page=$4
  20. endif
  21. 將URL 與$ 符合^(.*)/show/([0-9] )/([0-9] )?([/])?$
  22. 如果符合則
  23. 設定URL = $1 /show.php?itemid=$2&page=$3
  24. endif
  25. 將URL 與$ 匹配^(.*)/list/([0-9] )/([0-9] )?([/ ])?$
  26. 如果符合則
  27. 設定URL = $1/list.php?catid=$2&page=$3
  28. endif
  29. 將URL 與$ 配對^(.*)/([A- za-z0-9_-] )-c([0-9] )-([0-9] ).html$
  30. 如果符合則
  31. 設定URL = $1/list.php?catid=$3&page =$4
  32. endif
  33. 將URL 與$ 匹配^(.*)/([a-z] )/(.*).shtml$
  34. 如果符合則
  35. 設定URL = $1/$2/index .php?rewrite=$3
  36. endif
  37. 將URL 與$ 配對^(.*)/com/([a-z0-9_-] )/([a-z] )/(.*).html$
  38. 如果符合則
  39. 設定URL = $1/index.php?homepage=$2&file=$3&rewrite=$4
  40. endif
  41. 將URL 與$ 相符^(.*)/com/([a -z0-9_-] )/([a-z] )([/])?$
  42. 如果符合則
  43. 設定URL = $1/index.php?homepage=$2&file=$3
  44. endif
  45. 將URL 與$ 匹配^(.*)/com/([a-z0-9_-] )([/])?$
  46. 如果符合則
  47. 設定URL = $1/index.php?homepage =$2
  48. endif
複製碼

5、IIS6伺服器 請下載 http://download.destoon.com/rewrite/IIS_Rewrite.zip 規則已經設定好,請按readme.txt檔案內容進行操作 如果網站支援httpd.ini文件,請使用以下規則(參考http://download.destoon.com/rewrite/httpd.ini):

  1. [ISAPI_Rewrite]

  2. # Destoon B2B www.destoon.com
  3. # 3600 = 1 小時3600
  4. RepeatLimit 32

  5. # 保護httpd.ini 和httpd.parse.errors 檔案

  6. # 不透過HTTP 存取
  7. RewriteRule ^(.*).(asp|aspx|asa|asax|dll|jsp|cgi|fcgi|pl)(.*)$ /404.php
  8. 重寫規則^(.*)/file/(. *) .php(.*)$ /404.php
  9. RewriteRule ^(.*)-htm-(.*)$ $1.php?$2
  10. RewriteRule ^(.*)/show-([0 -9 ] )([-])?([0-9] )?.html$ $1/show.php?itemid=$2&page=$4
  11. RewriteRule ^(.*)/list-([0-9 ] ) ([-])?([0-9] )?.html$ $1/list.php?catid=$2&page=$4
  12. RewriteRule ^(.*)/show/([0-9] ) /( [0-9] )?([/])?$ $1/show.php?itemid=$2&page=$3
  13. RewriteRule ^(.*)/list/([0-9] )/([ 0- 9] )?([/])?$ $1/list.php?catid=$2&page=$3
  14. RewriteRule ^(.*)/([A-za-z0-9_-] )-c( [0 -9] )-([0-9] ).html$ $1/list.php?catid=$3&page=$4
  15. RewriteRule ^(.*)/com/([a-z0-9_-] )/ ([a-z] )/(.*).html$ $1/index.php?homepage=$2&file=$3&rewrite=$4
  16. RewriteRule ^(.*)/com/([a-z0-9_- ] ) /([a-z] )([/])?$ $1/index.php?homepage=$2&file=$3
  17. RewriteRule ^(.*)/com/([a-z0-9_-] )( [/ ])?$ $1/index.php?homepage=$2
  18. RewriteRule ^(.*)/([a-z] )/(.*).shtml$ $1/$2/index.php?rewrite=$3
複製程式碼

6、IIS7伺服器 規則(參考http://download.destoon.com/rewrite/web.config.txt)為:

  1. ;
  2. 規則>
  3. ;
複製程式碼

重寫生效後,請在網站後面然後》網站設定=》SEO優化=》網址重寫,選擇「開啟」提交。 然後進入各模組的模組設定「SEO設定」選擇對應偽靜態位址規則,選擇「更新位址」提交即可。

以上透過實例介紹了destoon URL Rewrite(偽靜態)的設定方法,希望對大家有幫助。

推薦閱讀:destoon入門教學與技巧實例



陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn