.htaccess 301重定向详细教程


重定向老域名.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

转载于:https://www.cnblogs.com/phpfans2012/archive/2012/03/15/2398552.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值