我有一个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)
Run Code Online (Sandbox Code Playgroud)
所有不属于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]
Run Code Online (Sandbox Code Playgroud)