URL Rewrite的設(shè)置方法
更新時(shí)間:2007年01月02日 00:00:00 作者:
URL Rewrite需要服務(wù)器的支持!在啟用此設(shè)置之前,請(qǐng)確保服務(wù)器上已作出了正確的設(shè)置,設(shè)置方法請(qǐng)參看下邊的“Apache下的設(shè)置方法”和“IIS下的設(shè)置方法”!
Apache下的設(shè)置方法
打開 Apache 的配置文件 httpd.conf 。
將#LoadModule rewrite_module modules/mod_rewrite前面的#去掉
在 httpd.conf中添加:
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteCond %{ENV:SCRIPT_URL} (?:index|dispbbs)[-0-9]+\.html
RewriteRule ^(.*?(?:index|dispbbs))-([-0-9]+)\.html$ $1.php?__is_apache_rewrite=1&__rewrite_arg=$2
</IfModule>
要實(shí)現(xiàn)asp帖子URL到php帖子的映射,在 第三步的<IfModule mod_rewrite.c>和</IfModule>之間添加:
RewriteMap tolowercase int:tolower
RewriteCond %{QUERY_STRING} (?:boardid|page|id|replyid|star|skin)\=\d+ [NC]
RewriteRule ^(.*(?:index|dispbbs))\.asp$ $1.php?${tolowercase:%{QUERY_STRING}}&__is_apache_rewrite=1
保存httpd.conf并重啟Apache。
Apache下的設(shè)置方法
復(fù)制代碼 代碼如下:
打開 Apache 的配置文件 httpd.conf 。
將#LoadModule rewrite_module modules/mod_rewrite前面的#去掉
在 httpd.conf中添加:
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteCond %{ENV:SCRIPT_URL} (?:index|dispbbs)[-0-9]+\.html
RewriteRule ^(.*?(?:index|dispbbs))-([-0-9]+)\.html$ $1.php?__is_apache_rewrite=1&__rewrite_arg=$2
</IfModule>
要實(shí)現(xiàn)asp帖子URL到php帖子的映射,在 第三步的<IfModule mod_rewrite.c>和</IfModule>之間添加:
RewriteMap tolowercase int:tolower
RewriteCond %{QUERY_STRING} (?:boardid|page|id|replyid|star|skin)\=\d+ [NC]
RewriteRule ^(.*(?:index|dispbbs))\.asp$ $1.php?${tolowercase:%{QUERY_STRING}}&__is_apache_rewrite=1
保存httpd.conf并重啟Apache。
相關(guān)文章
PHP的簡單跳轉(zhuǎn)提示的實(shí)現(xiàn)詳解
這篇文章主要介紹了PHP的簡單跳轉(zhuǎn)提示的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-03-03PHP三層結(jié)構(gòu)(下) PHP實(shí)現(xiàn)AOP
讓我們把注意力集中到中間服務(wù)層上來。中間服務(wù)層代碼比較簡單,只是調(diào)用數(shù)據(jù)訪問層代碼將留言保存到數(shù)據(jù)庫。2010-07-07PHP簡單實(shí)現(xiàn)解析xml為數(shù)組的方法
這篇文章主要介紹了PHP簡單實(shí)現(xiàn)解析xml為數(shù)組的方法,涉及php文件讀取、xml解析相關(guān)操作技巧,需要的朋友可以參考下2018-05-05解決php-fpm.service not found問題的辦法
這篇文章主要給大家介紹了解決php-fpm.service not found問題的辦法,文中詳細(xì)介紹的解決這個(gè)問題的思路與過程,分享出來給大家,如果有同樣問題的朋友就不用到處找解決辦法了,下面來一起看看吧。2017-06-06