麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 網站 > WEB服務 > 正文

Apache服務器下配置URL 態化的Rewrite規則

2020-05-27 13:13:00
字體:
來源:轉載
供稿:網友

 如何在Apache環境下配置Rewrite規則

Apache Rewrite 規則 環境 URL 靜態化是一個利于搜索引擎的設置,通過 URL 靜態化,達到原來是動態的 PHP 頁面轉換為靜態化的 HTML 頁面,當然,這里的靜態化是一種假靜態,目的只是提高搜索引擎的搜索量,Comsenz 旗下的產品 Discuz!、SupeSite/X-Space、ECShop、SupeV、UCHome 等都支持此功能。當然這個功能還需要服務器環境的支持,下面介紹一下如何在 Apache 服務器下配置 URL 靜態化的 Rewrite 規則。當然這里分兩種情況,一種是獨立主機用戶,這部分用戶擁有對主機的管理權限,因此配置起來比較方便一些。(注:這里就以 Discuz!6.1.0 的 Rewrite 規則為例,稍后在后面會列舉出其他產品的 Rewrite 規則。首先確定您使用的 Apache 版本,及是否加載了 mod_Rewrite 模塊。 Apache 1.x 的用戶請檢查 conf/httpd.conf 中是否存在如下兩段代碼: LoadModule Rewrite_module libexec/mod_Rewrite.soAddModule mod_Rewrite.c Apache 2.x 的用戶請檢查 conf/httpd.conf 中是否存在如下一段代碼: LoadModule Rewrite_module modules/mod_Rewrite.so如果存在,那么在配置文件(通常就是 conf/httpd.conf)中加入如下代碼。此時請務必注意,如果網站使用通過虛擬主機來定義,請務必加到虛擬主機配置,即 <VirtualHost> 中去,如果加在虛擬主機配置外部將可能無法使用,改好后將 Apache 重啟。<IfModule mod_Rewrite.c>RewriteEngine OnRewriteRule ^(.*)/archiver/((fid|tid)-[w-]+.html)$ $1/archiver/index.php?$2RewriteRule ^(.*)/forum-([0-9]+)-([0-9]+).html$ $1/forumdisplay.php?fid=$2&page=$3RewriteRule ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+).html$ $1/viewthread.php?tid=$2&extra=page%3D$4&page=$3RewriteRule ^(.*)/space-(username|uid)-(.+).html$ $1/space.php?$2=$3RewriteRule ^(.*)/tag-(.+).html$ $1/tag.php?name=$2</IfModule>如果沒有安裝 mod_Rewrite,您可以重新編譯 Apache,并在原有 configure 的內容中加入 --enable-Rewrite=shared,然后再在 Apache 配置文件中加入上述代碼即可。另外一種用戶是 Apache 虛擬主機用戶。在開始以下設置之前,請首先咨詢您的空間服務商,空間是否支持 Rewrite 以及是否支持對站點目錄中 .htaccess 的文件解析,否則即便按照下面的方法設置好了,也無法使用。 檢查論壇所在目錄中是否存在 .htaccess 文件,如果不存在,請手工建立此文件。Win32 系統下,無法直接建立 .htaccess 文件,您可以從其他系統中拷貝一份,或者在 Discuz.net 技術支持欄目中下載此文件。編輯并修改 .htaccess 文件,添加以下內容: # 將 RewriteEngine 模式打開RewriteEngine On# 修改以下語句中的 /discuz 為你的論壇目錄地址,如果程序放在根目錄中,請將 /discuz 修改為 /RewriteBase /discuz# Rewrite 系統規則請勿修改RewriteRule ^archiver/((fid|tid)-[w-]+.html)$ archiver/index.php?$1RewriteRule ^forum-([0-9]+)-([0-9]+).html$ forumdisplay.php?fid=$1&page=$2RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+).html$ viewthread.php?tid=$1&extra=page%3D$3&page=$2RewriteRule ^space-(username|uid)-(.+).html$ space.php?$1=$2RewriteRule ^tag-(.+).html$ tag.php?name=$1添加內容時,請遵照上面的提示,修改論壇所在的路徑,然后保存。將 .htaccess 文件上傳到論壇所在的目錄中。然后進入論壇系統設置的搜索引擎優化,根據需要開啟 URL 靜態化功能。下面簡單介紹一些其他產品的 Rewrite 規則。SupeSite/X-Space6.0 UC規則Apache 獨立主機用戶:<IfModule mod_Rewrite.c>RewriteEngine On###Rewrite 系統規則請勿修改RewriteRule ^/([0-9]+)/spacelist(.+)$ /index.php?uid/$1/action/spacelist/type$2 [L]RewriteRule ^/([0-9]+)/viewspace(.+)$ /index.php?uid/$1/action/viewspace/itemid$2 [L]RewriteRule ^/([0-9]+)/viewbbs(.+)$ /index.php?uid/$1/action/viewbbs/tid$2 [L]RewriteRule ^/([0-9]+)/(.*)$ /index.php?uid/$1/$2 [L]RewriteRule ^/([0-9]+)$ /index.php?uid/$1 [L]RewriteRule ^/action(.+)$ /index.php?action$1 [L]RewriteRule ^/category(.+)$ /index.php?action/category/catid$1 [L]RewriteRule ^/viewnews(.+)$ /index.php?action/viewnews/itemid$1 [L]RewriteRule ^/viewthread(.+)$ /index.php?action/viewthread/tid$1 [L]RewriteRule ^/mygroup(.+)$ /index.php?action/mygroup/gid$1 [L]</IfModule>Apache 虛擬主機用戶:### 將 RewriteEngine 模式打開RewriteEngine On### 修改以下語句中的 /SupeSite 修改為你的SupeSite目錄地址,如果程序放在根目錄中,請將 /SupeSite 修改為 /RewriteBase /### Rewrite 系統規則請勿修改RewriteRule ^([0-9]+)/spacelist(.+)$ index.php?uid/$1/action/spacelist/type$2 [L]RewriteRule ^([0-9]+)/viewspace(.+)$ index.php?uid/$1/action/viewspace/itemid$2 [L]RewriteRule ^([0-9]+)/viewbbs(.+)$ index.php?uid/$1/action/viewbbs/tid$2 [L]RewriteRule ^([0-9]+)/(.*)$ index.php?uid/$1/$2 [L]RewriteRule ^([0-9]+)$ index.php?uid/$1 [L]RewriteRule ^action(.+)$ index.php?action$1 [L]RewriteRule ^category(.+)$ index.php?action/category/catid$1 [L]RewriteRule ^viewnews(.+)$ index.php?action/viewnews/itemid$1 [L]RewriteRule ^viewthread(.+)$ index.php?action/viewthread/tid$1 [L]RewriteRule ^mygroup(.+)$ index.php?action/mygroup/gid$1 [L]ECShop2.6.0 規則Apache 獨立主機用戶:<IfModule mod_Rewrite.c>RewriteEngine OnRewriteRule ^(.*)/index.html$ $1/index.php RewriteRule ^(.*)/category$ $1/index.php [L]RewriteRule ^(.*)/feed-c([0-9]+).xml$ $1/feed.php?cat=$2 [L]RewriteRule ^(.*)/feed-b([0-9]+).xml$ $1/feed.php?brand=$2 [L]RewriteRule ^(.*)/feed.xml$ $1/feed.phpRewriteRule ^(.*)/category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)-([0-9]+)-(.+)-([a-zA-Z]+)(.*).html$ $1/category.php?id=$2&brand=$3&price_min=$4&price_max=$5&filter_attr=$6&page=$7&sort=$8&order=$9RewriteRule ^(.*)/category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*).html$ $1/category.php?id=$2&brand=$3&price_min=$4&price_max=$5&filter_attr=$6RewriteRule ^(.*)/category-([0-9]+)-b([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*).html$ $1/category.php?id=$2&brand=$3&page=$4&sort=$5&order=$6RewriteRule ^(.*)/category-([0-9]+)-b([0-9]+)-([0-9]+)(.*).html$ $1/category.php?id=$2&brand=$3&page=$4RewriteRule ^(.*)/category-([0-9]+)-b([0-9]+)(.*).html$ $1/category.php?id=$2&brand=$3RewriteRule ^(.*)/category-([0-9]+)(.*).html$ $1/category.php?id=$2RewriteRule ^(.*)/goods-([0-9]+)(.*).html$ $1/goods.php?id=$2RewriteRule ^(.*)/article_cat-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*).html$ $1/article_cat.php?id=$2&page=$3&sort=$4&order=$5RewriteRule ^(.*)/article_cat-([0-9]+)-([0-9]+)(.*).html$ $1/article_cat.php?id=$2&page=$3RewriteRule ^(.*)/article_cat-([0-9]+)(.*).html$ $1/article_cat.php?id=$2RewriteRule ^(.*)/article-([0-9]+)(.*).html$ $1/article.php?id=$2RewriteRule ^(.*)/brand-([0-9]+)-c([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+).html $1/brand.php?id=$2&cat=$3&page=$4&sort=$5&order=$6RewriteRule ^(.*)/brand-([0-9]+)-c([0-9]+)-([0-9]+)(.*).html $1/brand.php?id=$2&cat=$3&page=$4RewriteRule ^(.*)/brand-([0-9]+)-c([0-9]+)(.*).html $1/brand.php?id=$2&cat=$3RewriteRule ^(.*)/brand-([0-9]+)(.*).html $1/brand.php?id=$2RewriteRule ^(.*)/tag-(.*).html $1/search.php?keywords=$2RewriteRule ^(.*)/snatch-([0-9]).html$ $1/snatch.php?id=$2RewriteRule ^(.*)/group_buy-([0-9]).html$ $1/group_buy.php?act=view&id=$2</IfModule>

Apache 虛擬主機用戶:RewriteEngine On#RewriteBase /# direct one-word accessRewriteRule ^index.html$ index.php [L]RewriteRule ^category$ index.php [L]# access any object by its numeric identifierRewriteRule ^feed-c([0-9]+).xml$ feed.php?cat=$1 [L]RewriteRule ^feed-b([0-9]+).xml$ feed.php?brand=$1 [L]RewriteRule ^feed.xml$ feed.php [L]RewriteRule ^category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)-([0-9]+)-(.+)-([a-zA-Z]+)(.*).html$ category.php?id=$1&brand=$2&price_min=$3&price_max=$4&filter_attr=$5&page=$6&sort=$7&order=$8 [QSA,L]RewriteRule ^category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)(.*).html$ category.php?id=$1&brand=$2&price_min=$3&price_max=$4&filter_attr=$5 [QSA,L]RewriteRule ^category-([0-9]+)-b([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*).html$ category.php?id=$1&brand=$2&page=$3&sort=$4&order=$5 [QSA,L]RewriteRule ^category-([0-9]+)-b([0-9]+)-([0-9]+)(.*).html$ category.php?id=$1&brand=$2&page=$3 [QSA,L]RewriteRule ^category-([0-9]+)-b([0-9]+)(.*).html$ category.php?id=$1&brand=$2 [QSA,L]RewriteRule ^category-([0-9]+)(.*).html$ category.php?id=$1 [QSA,L]RewriteRule ^goods-([0-9]+)(.*).html$ goods.php?id=$1 [QSA,L]RewriteRule ^article_cat-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*).html$ article_cat.php?id=$1&page=$2&sort=$3&order=$4 [QSA,L]RewriteRule ^article_cat-([0-9]+)-([0-9]+)(.*).html$ article_cat.php?id=$1&page=$2 [QSA,L]RewriteRule ^article_cat-([0-9]+)(.*).html$ article_cat.php?id=$1 [QSA,L]RewriteRule ^article-([0-9]+)(.*).html$ article.php?id=$1 [QSA,L]RewriteRule ^brand-([0-9]+)-c([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+).html brand.php?id=$1&cat=$2&page=$3&sort=$4&order=$5 [QSA,L]RewriteRule ^brand-([0-9]+)-c([0-9]+)-([0-9]+)(.*).html brand.php?id=$1&cat=$2&page=$3 [QSA,L]RewriteRule ^brand-([0-9]+)-c([0-9]+)(.*).html brand.php?id=$1&cat=$2 [QSA,L]RewriteRule ^brand-([0-9]+)(.*).html brand.php?id=$1 [QSA,L]RewriteRule ^tag-(.*).html search.php?keywords=$1 [QSA,L]RewriteRule ^snatch-([0-9]+).html$ snatch.php?id=$1 [QSA,L]RewriteRule ^group_buy-([0-9]+).html$ group_buy.php?act=view&id=$1 [QSA,L]RewriteRule ^auction-([0-9]+).html$ auction.php?act=view&id=$1 [QSA,L]SupeV1.0beta 規則Apache 獨立主機用戶:<IfModule mod_Rewrite.c>RewriteEngine OnRewriteRule ^(.*)/ivideo(-tv-([0-9]+))?(-ti-([0-9]+))?(-tc-([0-9]+))?(-page-([0-9]+))?.html$ $1/ivideo.php?tv=$3&ti=$5&tc=$7&page=$9RewriteRule ^(.*)/ispecial(-tv-([0-9]+))?(-ti-([0-9]+))?(-tc-([0-9]+))?(-page-([0-9]+))?.html$ $1/ispecial.php?tv=$3&ti=$5&tc=$7&page=$9RewriteRule ^(.*)/icategory.html$ $1/icategory.phpRewriteRule ^(.*)/category-cid-([0-9]+)(-tag-([^-]*))?(-timelimit-([0-9]+))?(-orderlimit-([0-9]+))?(-page-([0-9]+))?.html$ $1/category.php?cid=$2&tag=$4&timelimit=$6&orderlimit=$8&page=$10RewriteRule ^(.*)/vspace-(mid|username)-(.+).html$ $1/vspace.php?$2=$3RewriteRule ^(.*)/video-(vid|ivid)-(.+).html$ $1/video.php?$2=$3RewriteRule ^(.*)/special-spid-([0-9]+).html$ $1/special.php?spid=$2</IfModule>Apache 虛擬主機用戶:# 將 RewriteEngine 模式打開RewriteEngine On# 修改以下語句中的 /SupeV 為你的播客目錄地址,如果程序放在根目錄中,請將 /SupeV 修改為 /RewriteBase /SupeV# Rewrite 系統規則請勿修改 RewriteRuleRewriteRule ^ivideo(-tv-([0-9]+))?(-ti-([0-9]+))?(-tc-([0-9]+))?(-page-([0-9]+))?.html$ ivideo.php?tv=$2&ti=$4&tc=$6&page=$8RewriteRule ^ispecial(-tv-([0-9]+))?(-ti-([0-9]+))?(-tc-([0-9]+))?(-page-([0-9]+))?.html$ ispecial.php?tv=$2&ti=$4&tc=$6&page=$8RewriteRule ^icategory.html$ icategory.phpRewriteRule ^category-cid-([0-9]+)(-tag-([^-]*))?(-timelimit-([0-9]+))?(-orderlimit-([0-9]+))?(-page-([0-9]+))?.html$ category.php?cid=$1&tag=$3&timelimit=$5&orderlimit=$7&page=$9RewriteRule ^vspace-(mid|username)-(.+).html$ vspace.php?$1=$2RewriteRule ^video-(vid|ivid)-(.+).html$ video.php?$1=$2RewriteRule ^special-spid-([0-9]+).html$ special.php?spid=$1UCHome1.0 規則Apache 獨立主機用戶:RewriteEngine On RewriteRule ^/(space|network)-(.+).html$ /$1.php?Rewrite=$2 [L] RewriteRule ^/(space|network).html$ /$1.php [L] RewriteRule ^/([0-9]+)$ /space.php?uid=$1 [L] Apache 虛擬主機用戶:RewriteEngine On RewriteBase / RewriteRule ^(space|network)-(.+).html$ $1.php?Rewrite=$2 [L] RewriteRule ^(space|network).html$ $1.php [L] RewriteRule ^([0-9]+)$ space.php?uid=$1 [L]

當然,在我們每個發布的程序包中,都有關于此版本程序對應的 Rewrite 規則,大家可以在那里找到相對應的 Rewrite 規則。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 中国国语毛片免费观看视频 | 色悠悠久久久久 | 午夜小视频免费观看 | 精品中文字幕视频 | 久久综合色区 | 国产精品久久久久久久久久久久久久久 | 精品国产一区二区三区天美传媒 | 国产精品啪一品二区三区粉嫩 | 久久久久久久免费精品 | 99亚洲精品| 亚洲aⅴ免费在线观看 | 国产乱一区二区三区视频 | 久在线观看福利视频69 | 亚洲91精品 | 视频一区二区三区在线观看 | 国产一国产一级毛片视频在线 | 99精品电影 | 亚洲成人国产综合 | 欧美国产永久免费看片 | 成人爱爱电影 | 亚洲网站一区 | 国产成人精品日本亚洲语音 | 欧美一级α | 爽毛片 | 欧美3p激情一区二区三区猛视频 | 国产精品久久久久久久久久 | 亚洲乱码精品久久久久 | 久久久久久久久亚洲精品 | 羞羞答答tv | 成av在线 | 欧美囗交 | www.成人在线 | 人人做人人看 | 曰批全过程40分钟免费视频多人 | 伊人一二三四区 | 黄在线| 国产在线精品一区二区不卡 | 亚洲小视频在线 | 亚洲国产小视频 | 久久99国产精品视频 | 在线看毛片的网站 |