URL Rewrite的設定方法_PHP教程

來源:互聯網
上載者:User
URL Rewrite需要伺服器的支援!在啟用此設定之前,請確保伺服器上已作出了正確的設定,設定方法請參看下邊的“Apache下的設定方法”和“IIS下的設定方法”!
Apache下的設定方法
複製代碼 代碼如下:
開啟 Apache 的設定檔 httpd.conf 。
將#LoadModule rewrite_module modules/mod_rewrite前面的#去掉
在 httpd.conf中添加:

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


要實現asp文章URL到php文章的映射,在 第三步的和之間添加:
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。

http://www.bkjia.com/PHPjc/317645.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/317645.htmlTechArticleURLRewrite需要伺服器的支援!在啟用此設定之前,請確保伺服器上已作出了正確的設定,設定方法請參看下邊的“Apache下的設定方法”和“...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.