网站虚拟主机域名访问绑定和301跳转.htaccess伪静态规则301重定

.htaccess这个模块是apache的一个算是叫扩展示模板吧,要能让它可以运行必须在RewriteEngine:让下面的rewrite功能打开或关闭。on是打开;off是关闭,可以的。
 

重定向老域名.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.otherdomain.com/otherfile/other.php [R=301,L]

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

#不加斜杠请求的地址是/wwwroot/www.111cn.net/news/

 代码如下复制代码

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

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

RewriteCond %{HTTP_HOST} ^124.173.133.154 [NC]
RewriteRule (.*)$ http://www.111cn.net/news/$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的缩写,意思是最后一句了。

Leave a Comment