apache rewrite 讲解
Apache Rewrite实例2007-03-04 11:25<VirtualHost *:80>
ServerAdmin host@discuz.com
DocumentRoot D:/www
ServerName www.xiaojia.com
ServerAlias xiaojia.com xiaojia.net
ErrorLog D:/www/logs/xiaojia.com-error_log
CustomLog D:/www/logs/xiaojia.com-access_log%Y%m%d combined
# Alias /upimg "/home/www/wwwroot/phpchina.cn/upimg/"
# Alias /wiki "/home/www/wwwroot/phpchina.cn/wiki/"
<IfModule mod_rewrite.c>
RewriteEngine On
# RewriteCond %{HTTP_HOST} !phpchina.com [OR]
# RewriteCond %{HTTP_HOST} !www.phpchina.com
# RewriteRule ^(.*)$ http://www.phpchina.com$1 [R=301,L]
RewriteRule ^(.*)/archiver/([a-z0-9\-]+\.html)$ $1/archiver/index.php?$2
RewriteRule ^(.*)/forum-([0-9]+)-([0-9]+)\.html$ $1/forumdisplay.php?fid=$2&page=$3
RewriteRule ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/viewthread.php?tid=$2&extra=page\%3D$4&page=$3
RewriteRule ^(.*)/profile-(username|uid)-(.+)\.html$ $1/viewpro.php?$2=$3
</IfModule>
</VirtualHost>
ServerAdmin host@discuz.com
DocumentRoot D:/www
ServerName www.xiaojia.com
ServerAlias xiaojia.com xiaojia.net
ErrorLog D:/www/logs/xiaojia.com-error_log
CustomLog D:/www/logs/xiaojia.com-access_log%Y%m%d combined
# Alias /upimg "/home/www/wwwroot/phpchina.cn/upimg/"
# Alias /wiki "/home/www/wwwroot/phpchina.cn/wiki/"
<IfModule mod_rewrite.c>
RewriteEngine On
# RewriteCond %{HTTP_HOST} !phpchina.com [OR]
# RewriteCond %{HTTP_HOST} !www.phpchina.com
# RewriteRule ^(.*)$ http://www.phpchina.com$1 [R=301,L]
RewriteRule ^(.*)/archiver/([a-z0-9\-]+\.html)$ $1/archiver/index.php?$2
RewriteRule ^(.*)/forum-([0-9]+)-([0-9]+)\.html$ $1/forumdisplay.php?fid=$2&page=$3
RewriteRule ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/viewthread.php?tid=$2&extra=page\%3D$4&page=$3
RewriteRule ^(.*)/profile-(username|uid)-(.+)\.html$ $1/viewpro.php?$2=$3
</IfModule>
</VirtualHost>
补充:Php教程,Php常用代码