linux apache 偽靜態詳細說明

來源:互聯網
上載者:User

linux apache 偽靜態詳細說明
一 開啟 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>


四 要實現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。

下面看一下.htaccess檔案寫法,這是dz論壇的做法

# 將 rewriteengine 模式開啟
rewriteengine on
# 修改以下語句中的 /bbs 為你的論壇目錄位址,如果程式放在根目錄中,請將 /bbs 修改為 /

rewritebase /bbs
# rewrite 系統規則請勿修改
rewriterule ^archiver/((fid|tid)-[w-]+.html)$ archiver/index.php?$1
rewriterule ^forum-([0-9]+)-([0-9]+).html$ forumdisplay.php?fid=$1&page=$2
rewriterule ^thread-([0-9]+)-([0-9]+)-([0-9]+).html$ viewthread.php?tid=$1&extra=page%3d$3&page=$2
rewriterule ^space-(username|uid)-(.+).html$ space.php?$1=$2
rewriterule ^tag-(.+).html$ tag.php?name=$1

1、修改apache 的設定檔 httpd.conf 。將#loadmodule rewrite_module modules/mod_rewrite前面的#去掉

2、在 httpd.conf中添加:

<ifmodule mod_rewrite.c>
rewriteengine on
#...
</ifmodule>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.