htaccess 将所有请求重定向到某个URL地址的规则
用如下的代码即可实现:
RewriteEngine On
RewriteCond %{REQUEST_URI} !=/tempIndex.html RewriteRule ^ /tempIndex.html [R=301]
附,修改.htaccess实现301重定向
一个.htaccess里面的内容:
# Use PHP5CGI as default
# 修改以下语句中的 /discuz 为你的论坛目录地址,如果程序放在根目录中,请将 /discuz 修改为 / # Rewrite 系统规则请勿修改
RewriteCond %{HTTP_HOST} !^www.it.net.cn$ [NC]
VIA
直接编辑.htaccess的方法。
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC] RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
2.重定向www.domain.com到domain.com
RewriteEngine On
RewriteCond %{HTTP_HOST} !^domain.com$ [NC] RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]
3.重定向olddomain.com到www.newdomain.com
RewriteEngine On
RewriteCond %{HTTP_HOST} !olddomain.com$ [NC] RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,R=301]
4.重定向olddomain.com to newdomain.com
RewriteEngine On
RewriteBase / RewriteCond %{HTTP_HOST} !olddomain.com$ [NC] RewriteRule ^(.*)$ http://newdomain.com/$1 [L,R=301]
5.重定向domain.com/file/file.php 到 otherdomain.com/otherfile/other.php
RewriteCond %{HTTP_HOST} ^www.domain.com$
(责任编辑:IT)RewriteRule ^file/file.php$ http://www.otherdomain.com/otherfile/other.php [R=301,L] |