我有一个drupal网站,已经分裂成两个单独的网站,现在我需要设置一些重写规则,以推动流量到新的网站。
原来的网站如下:
http://www.website.com (frontpage)
http://www.website.com/web1/subpage1 (subpage)
http://www.website.com/web1/subpage2 (subpage)
http://www.website.com/subpage3 (subpage)
http://www.website.com/subpage4 (subpage)所有对不属于web1类别的子页面的引用都已从网站中删除,但是这些页面仍然被发布,并且仍然显示在Google中。
我需要的是一条重写规则,如果用户试图访问一个非首页而不是web1类别的页面,则可以将其从"website.com“重定向到"new-website.com”的首页。
我认为重写规则检查URI中的字符串"web1“可以解决我的问题,但不幸的是,我不知道如何编写语法。
任何帮助都将不胜感激。
提前谢谢。
编辑:
我的htaccess文件使用@zessx建议的解决方案:
Options -Indexes
Options +FollowSymLinks
DirectoryIndex index.php
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^my-website\.com$ [NC]
RewriteRule ^(.*)$ http://www.my-website.com/$1 [L,R=301]
RewriteCond %{REQUEST_URI} !web1
RewriteRule ^(.+)$ http://www.my-new-website.com [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]发布于 2012-08-07 14:26:26
这就是你需要的:
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} !web1
RewriteRule ^(.+)$ http://new-website.com [L,R=301]发布于 2012-08-09 13:44:29
我的一位同事找到了一个解决方案:
RewriteCond %{REQUEST_URI} !^/web1(/|$)
RewriteCond %{REQUEST_URI} !^/admin(/|$)
RewriteCond %{REQUEST_URI} !^/$
RewriteRule ^([\w/]*)$ http://www.new-website.com [L]`https://stackoverflow.com/questions/11844155
复制相似问题