Apache 2.x 服务器中的URL重写的配置和应用
2008-01-10 00:00:00 来源:WEB开发网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]
- ››apache设置域名绑定 以及绑定不起作用的排查
- ››apache rewrite将指定URL转向指定的几个服务器
- ››Url传参数被IE截断的解决方案
- ››apache配置文件httpd.comf部分参数说明
- ››URL和HttpCore,HttpClien(不用DNS解析,直接访问...
- ››Apache+Mysql+PHP+phpMyAdmin+Mac OS X 10.7 Lion...
- ››apache+tomcat负载均衡_项目实例
- ››apache mysql php 源码编译使用
- ››Apache添加mod_aspdotnet.so支持ASP.NET配置指南
- ››Apache中改变php.ini的路径
- ››url2bmp网页截图工具 命令行参数说明
- ››Apache2.2与Tomcat6整合及虚拟主机配置
更多精彩
赞助商链接