重定向老域名.com到www.新域名.com

RewriteEngine On
RewriteCond %{HTTP_HOST} !老域名.com$ [NC]
RewriteRule ^(.*)$ http://www.新域名.com/$1 [L,R=301]



 

重定向老域名.com to 新域名.com

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !老域名.com$ [NC]
RewriteRule ^(.*)$ http://新域名.com/$1 [L,R=301]


 

重定向domain.com/file/file.php 到 otherdomain.com/otherfile/other.php

RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteRule ^file/file.php$ http://www.hzhuti.com/nokia/n86/ [R=301,L]


RewriteBase /news
RewriteCond %{HTTP_HOST} ^hzhuti.com [NC]
RewriteRule com(.*)$ http://www.hzhuti.com$1 [L,R=301]


 


#不加斜杠请求的地址是/wwwroot/www.zhutiai.com/news/

 

RewriteCond %{HTTP_HOST} ^hzhuti.com [NC]
RewriteRule (.*)$ http://www.hzhuti.com/ [L,R=301]

RewriteCond %{HTTP_HOST} ^124.173.133.154 [NC]
RewriteRule com(.*)$ http://www.hzhuti.com [L,R=301]

RewriteCond %{HTTP_HOST} ^124.173.133.154 [NC]
RewriteRule (.*)$ http://www.hzhuti.com/nokia/n85/$1[L,R=301]


# 修改以下语句中的 /discuz 为你的论坛目录地址,如果程序放在根目录中,请将 /discuz 修改为 /
RewriteBase /

# Rewrite 系统规则请勿修改

RewriteCond %{HTTP_HOST} !^www.111cn.net$ [NC]
RewriteRule ^(.*)$ http://www.111cn.net/$1 [L,R=301]
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


 


[NC]:no case的缩写。意思是忽略大小写,a-z和A-Z是没有差别的。
[NC,OR]:OR=AND。意思是此句要紧接着下一句语法。
[R=301,L]:R=301:redirect的缩写。意思是用301永久转向(当网址在上述名单内,就自动转向至你指定的网址);L:Last的缩写,意思是最后一句了。


更多详细内容请查看:http://www.111cn.net/phper/apache/42188.htm