【发布时间】:2012-08-27 07:22:12
【问题描述】:
我有 2 个域指向同一个目录,现在我想将一些 URL 重定向到一个特定的域,其余的应该在主域上。
我有一个域 www.xyz.com 这是主域站点将使用该域打开,从这个域我想将特定的 URL 重定向到不同的域,所以如果有人打开 www.xyz.com/a/theatre 然后它应该重定向到 www.abc.com/a/theatre。现在从同一个新域中,如果有人单击 URL 中没有“/a/theatre”的 URL,那么它应该重定向回主域。所以如果有人打开 www.abc.com/a/classes 那么它应该重定向到 www.xyz.com/a/classes
我使用了以下规则但不起作用,
RewriteCond %{HTTP_HOST} ^www.xyz.com$ [NC]
RewriteCond %{REQUEST_URI} ^/a/theatre$
RewriteRule (.*)$ http://www.abc.com/a/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www.abc.com$ [NC]
RewriteCond %{REQUEST_URI} !^/a/theatre
RewriteRule (.*)$ http://www.xyz.com/a/$1 [NC,L,R=301]
感谢任何帮助。 谢谢!
这是我的 htaccess 中的所有代码,我已经在这个域上安装了 Joomla。
Options -Indexes
RewriteEngine on
RewriteBase /seo
RewriteCond %{HTTP_HOST} ^www.mcleancenter.org$ [NC]
RewriteCond %{REQUEST_URI} ^/seo/alden-theatre$
RewriteRule ^/?seo/(.*)$ http://www.aldentheatre.org/seo/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www.aldentheatre.org$ [NC]
RewriteCond %{REQUEST_URI} !^/seo/alden-theatre
RewriteRule ^/?seo/(.*)$ http://www.mcleancenter.org/seo/$1 [NC,L,R=301]
########## Begin - Joomla! core SEF Section
#
#RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
#
########## End - Joomla! core SEF Section
【问题讨论】:
标签: .htaccess mod-rewrite redirect