我有一个 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]