[英]Redirect paths with .htaccess from main domain to subdomain - multisite installation
I have my drupal setup at www.my-main-domain.com, i have drupal multisite installation at subdomain.my-main-domain.com 我在www.my-main-domain.com上安装了drupal,在subdomain.my-main-domain.com上安装了drupal多站点。
I want to redirect all: 我想全部重定向:
www.my-main-domain.com/user , www.my-main-domain.com/users, www.my-main-domain.com/user/*
www.my-main-domain.com/user、www.my-main-domain.com/users、www.my-main-domain.com/user/*
paths to my subdomain subdomain: 我的子域子域的路径:
my-main-domain.com/user , subdomain.my-main-domain.com/users, subdomain.my-main-domain.com/*
my-main-domain.com/user,subdomain.my-main-domain.com/users,subdomain.my-main-domain.com/*
respectively. 分别。
I'm writing following in my .htaccess file: 我在我的.htaccess文件中编写以下内容:
RewriteBase /
RedirectMatch 301 ^/users/(.*)$ http://subdomain.my-main-domain.com/users/$1
RedirectMatch 301 ^/user/(.*)$ http://subdomain.my-main-domain.com/user/$1
RedirectMatch 301 ^/users$ http://subdomain.my-main-domain.com/users
RedirectMatch 301 ^/user$ http://subdomain.my-main-domain.com/user
But it redirects to subdomain but in continues loop and hence ends with blank display. 但是它重定向到子域,但继续循环,因此以空白显示结束。
Please note that it's multisite installation with common root .htaccess file. 请注意,它是具有通用根.htaccess文件的多站点安装。 I have tried path redirect drupal module but its not supporting internal paths redirection saying paths already in use.
我已经尝试了路径重定向drupal模块,但是它不支持内部路径重定向,即已在使用的路径。
Please help. 请帮忙。 thanks
谢谢
Use mod_rewrite
instead to control the host name in rewrite condition. 改用
mod_rewrite
在重写条件下控制主机名。
RewriteEngine On
RewriteCond %{HTTP_HOST} ^my-main-domain\.com$ [NC]
RewriteRule ^(users?)(/.*)?$ http://subdomain.my-main-domain.com/$1$2 [L,R=301,NC]
PS: Also note that your 4 rules can be combined into one as shown above. PS:另外请注意,您的4条规则可以合并为一条,如上所示。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.