您现在的位置: > 首页 > 网站建设 > 服务器
>> 最新教程
>> 热门教程
>> 最新游戏资讯
>> 热门游戏资讯
Apache 2.x 服务器中的URL重写的配置和应用
作者:本站                来自:安迪教程网                 加入时间:08-07-22                进入论坛讨论

  2、关于Apache 2.x URL重写规则的应用;

  Apache 2.x 的rewrite模块调用和配置比较容易,这并不是目的。在应用为王的年代里,在服务器程序可选择的今天,应用才是王道。现在我就举例,说一下两个应用。一个vbb论坛的URL重写成类似的静态网页地址的,另一个就是drupal的URL地址重写。

  关于vbb论坛程序的URL规则重写,我是从国外论坛看到的。可能有的朋友需要,对vbb 3.5或以上版本有效。我测试的是3.6版本,至于在其它版本上能否可行,这个由你来测试。我不敢保证。

  2.1 vbb 论坛的URL地址重写配置

  首先:在您的论坛程序存放的家目录下,创建一个.htaccess 文件;

  内空如下:

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^getdaily.html$ search.php?do=getdaily [L]
RewriteRule ^getdaily([0-9]+).html$ search.php?do=getdaily&f=$1 [L]
RewriteRule ^unanswered.html$ search.php?do=process&replyless=1&replylimit=0&dontcache=1   [L]
RewriteRule ^unanswered([0-9]+).html$ search.php?do=process&replyless=1&replylimit=0&dontcache=1&forumchoice=$1&childforums=1 [L]
RewriteRule ^forum([0-9]+).html$    forumdisplay.php?f=$1     [L]
RewriteRule ^forum([0-9]+)-([0-9]+)-([a-z]+)-(.*)-([0-9]+)-(.*).html$ forumdisplay.php?f=$1&page=$2&sort=$3&order=$4&pp=$5&daysprune=$6 [L]
RewriteRule ^forum([0-9]+)-(.*)-([a-z]+)-([a-z]+).html$  forumdisplay.php?f=$1&daysprune=$2&order=$3&sort=$4   [L]
RewriteRule ^announcement([0-9]+).html$   announcement.php?f=$1   [L]
RewriteRule ^announcement([0-9]+)-([0-9]+).html$  announcement.php?f=$1&announcementid=$2 [L]
RewriteRule ^thread([0-9]+).html$   showthread.php?t=$1   [L]
RewriteRule ^thread([0-9]+)-([0-9]+).html$  showthread.php?t=$1&page=$2   [L]
RewriteRule ^getnew.html$ search.php?do=getnew [L]
RewriteRule ^getnew([0-9]+).html$ search.php?do=getnew&f=$1 [L]
RewriteRule ^printthread([0-9]+).html$  printthread.php?t=$1   [L]
RewriteRule ^sendthread([0-9]+).html$  sendmessage.php?do=sendtofriend&t=$1 [L]
RewriteRule ^referthread([0-9]+)-([0-9]+).html$ showthread.php?t=$1&referrerid=$2  [L]
RewriteRule ^lastpostinthread([0-9]+).html$ showthread.php?goto=lastpost&t=$1 [L]
RewriteRule ^newpostinthread([0-9]+).html$ showthread.php?goto=newpost&t=$1 [L]
RewriteRule ^nextnewesttothread([0-9]+).html$  showthread.php?t=$1&goto=nextnewest  [L]
RewriteRule ^nextoldesttothread([0-9]+).html$  showthread.php?t=$1&goto=nextoldest  [L]
RewriteRule ^post([0-9]+).html$   showthread.php?p=$1   [L]
RewriteRule ^post([0-9]+)-([0-9]+).html$  showpost.php?p=$1&postcount=$2  [L]
RewriteRule ^post([0-9]+)-([0-9]+)-([0-9]+).html$ showthread.php?p=$1&page=$2&pp=$3  [L]
RewriteRule ^thread([0-9]+)-([a-z]+).html$ showthread.php?mode=$2&t=$1  [L]
RewriteRule ^post([0-9]+)-([a-z]+).html$ showthread.php?p=$1&mode=$2  [L]

<<< << < 1 2 3 4 > >> >>>
联系方式:QQ:6084884 email:agwcn@126.com 粤ICP备05055782号
本网站中发布的文章只代表发表人的个人观点,不代表安迪教程网网站的立场
copyright© 2000-2004 安迪教程网 All rights reserved agwcn.com