linux apache 伪静态详细说明

作者:简简单单 2011-04-29

linux 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。

下面看一下.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中添加:


rewriteengine on
#...

相关文章

精彩推荐