国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > Apache > 正文

apache 偽靜態配置方法

2024-08-27 18:21:59
字體:
來源:轉載
供稿:網友

Apache偽靜態html(URL Rewrite)設置法

一 打開 Apache 的配置文件 httpd.conf 。

二 將#LoadModule rewrite_module modules/mod_rewrite前面的#去掉

三 在 httpd.conf中添加:

  1. <IfModule mod_rewrite.c> 
  2.     RewriteEngine On 
  3.     #RewriteCond %{ENV:SCRIPT_URL} (?:index|dispbbs)[-0-9]+.html 
  4.     RewriteRule ^(.*?(?:index|dispbbs))-([-0-9]+).html$ $1.php? 
  5. __is_apache_rewrite=1&__rewrite_arg=$2 
  6. </IfModule> 
  7. <ifmodule mod_rewrite.c> 
  8.  RewriteEngine On 
  9.  RewriteRule /news/top2007,(d+).html$   /news/readmore.php?id=$1 
  10. </ifmodule> 

四 保存httpd.conf并重啟apache。

Apache Web Server(獨立主機用戶)

首先確定您使用的 Apache 版本,及是否加載了 mod_rewrite 模塊。

Apache 1.x 的用戶請檢查 conf/httpd.conf 中是否存在如下兩段代碼:

LoadModule rewrite_module libexec/mod_rewrite.so

AddModule mod_rewrite.c

Apache 2.x 的用戶請檢查 conf/httpd.conf 中是否存在如下一段代碼:

LoadModule rewrite_module modules/mod_rewrite.so

如果存在,那么在配置文件(通常就是 conf/httpd.conf)中加入如下代碼。此時請務必注意,如果網站使用通過虛擬主機來定義,請務必加到虛擬主機配置,即 <VirtualHost>中去,如果加在虛擬主機配置外部將可能無法使用。改好后然后將 Apache 重啟。

  1. <IfModule mod_rewrite.c>  
  2. RewriteEngine On  
  3. RewriteRule ^(.*)/ivideo(-tv-([0-9]+))?(-ti-([0-9]+))?(-tc-([0-9]+))?(-page- 
  4. ([0-9]+))?.html$ $1/ivideo.php?tv=$3&ti=$5&tc=$7&page=$9  
  5. RewriteRule ^(.*)/ispecial(-tv-([0-9]+))?(-ti-([0-9]+))?(-tc-([0-9]+))?(-page- 
  6. ([0-9]+))?.html$ $1/ispecial.php?tv=$3&ti=$5&tc=$7&page=$9  
  7. RewriteRule ^(.*)/icategory.html$ $1/icategory.php  
  8. RewriteRule ^(.*)/category-cid-([0-9]+)(-tag-([^-]*))?(-timelimit-([0-9]+))?(- 
  9. orderlimit-([0-9]+))?(-page-([0-9]+))?.html$ $1/category.php? 
  10. cid=$2&tag=$4&timelimit=$6&orderlimit=$8&page=$10  
  11. RewriteRule ^(.*)/vspace-(mid|username)-(.+).html$ $1/vspace.php?$2=$3  
  12. RewriteRule ^(.*)/video-(vid|ivid)-(.+).html$ $1/video.php?$2=$3  
  13. RewriteRule ^(.*)/special-spid-([0-9]+).html$ $1/special.php?spid=$2  
  14. </IfModule>  

如果沒有安裝 mod_rewrite,您可以重新編譯 Apache,并在原有 configure 的內容中加入 --enable-rewrite=shared,然后再在 Apache 配置文件中加入上述代碼即可。

Apache Web Server(虛擬主機用戶)

在開始以下設置之前,請首先咨詢您的空間服務商,空間是否支持 Rewrite 以及是否支持對站點目錄中 .htaccess 的文件解析,否則即便按照下面的方法設置好了,也無法使用。

檢查播客所在目錄中是否存在 .htaccess 文件,如果不存在,請手工建立此文件。Win32系統下,無法直接建立 .htaccess 文件,您可以從其他系統中拷貝一份,或者在discuz.net 技術支持欄目中下載此文件。編輯并修改 .htaccess 文件,添加以下內容:

  1. #將 RewriteEngine 模式打開 RewriteEngine On  
  2. # 修改以下語句中的 /supev 為你的播客目錄地址,如果程序放在根目錄中,請將 /supev 修改為 /  
  3. ?RewriteBase /supev  
  4.  
  5. # Rewrite 系統規則請勿修改 RewriteRule 
  6.  
  7. RewriteRule ^ivideo(-tv-([0-9]+))?(-ti-([0-9]+))?(-tc-([0-9]+))?(-page-([0-9] 
  8. +))?.html$ ivideo.php?tv=$2&ti=$4&tc=$6&page=$8  
  9. RewriteRule ^ispecial(-tv-([0-9]+))?(-ti-([0-9]+))?(-tc-([0-9]+))?(-page-([0- 
  10. 9]+))?.html$ ispecial.php?tv=$2&ti=$4&tc=$6&page=$8  
  11. RewriteRule ^icategory.html$ icategory.php  
  12. RewriteRule ^category-cid-([0-9]+)(-tag-([^-]*))?(-timelimit-([0-9]+))?(- 
  13. orderlimit-([0-9]+))?(-page-([0-9]+))?.html$ category.php? 
  14. cid=$1&tag=$3&timelimit=$5&orderlimit=$7&page=$9  
  15. RewriteRule ^vspace-(mid|username)-(.+).html$ vspace.php?$1=$2  
  16. RewriteRule ^video-(vid|ivid)-(.+).html$ video.php?$1=$2  
  17. RewriteRule ^special-spid-([0-9]+).html$ special.php?spid=$1 
  18.  
  19. <VirtualHost *:80> 
  20. DocumentRoot /home/www_php168 
  21. ServerName www.111cn.cn 
  22. <IfModule mod_rewrite.c> 
  23. RewriteEngine On 
  24. RewriteRule ^(.*)/list-([0-9]+)-([0-9]+).htm$ $1/list.php?fid=$2&page=$3 
  25. RewriteRule ^(.*)/bencandy-([0-9]+)-([0-9]+)-([0-9]+).htm$ $1/bencandy.php? 
  26. fid=$2&id=$3&page=$4 
  27. </IfModule> 
  28. </VirtualHost> 

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 镇雄县| 卢龙县| 历史| 叶城县| 民勤县| 凉城县| 平昌县| 皮山县| 扎赉特旗| 偃师市| 铜梁县| 仁怀市| 黄梅县| 五常市| 康马县| 凤山县| 滨海县| 元朗区| 拉萨市| 梁平县| 年辖:市辖区| 合山市| 荣昌县| 丹棱县| 陇南市| 宁安市| 龙游县| 宁夏| 察哈| 波密县| 田林县| 会理县| 中山市| 都兰县| 蓬溪县| 综艺| 威海市| 社旗县| 鹿邑县| 新邵县| 社旗县|