2012-08-27 3 views
1

동일한 도메인을 가리키는 2 개의 도메인이 있습니다. 이제 일부 URL을 특정 도메인으로 리디렉션하고 나머지는 메인 도메인에 있어야합니다.htaccess 특정 URL을 다른 도메인으로 리디렉션

나는 하나의 도메인 www.xyz.com을 가지고 있습니다. 이것은이 도메인에서이 도메인으로 열릴 메인 도메인 사이트입니다. 특정 도메인을 다른 도메인으로 리디렉션하고 싶으므로 누군가 www.xyz.com/a/theatre를 열면됩니다. www.abc.com/a/theatre로 리디렉션해야합니다. 그리고 이제이 새로운 도메인에서 누군가가 URL에 "/ a/theater"가없는 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 

답변

1

당신은 규칙의 정규식의 전면에 ^/?a/을 추가하여 최고의 /a/을 일치해야합니다.

RewriteCond %{HTTP_HOST} ^www.xyz.com$ [NC]  
RewriteCond %{REQUEST_URI} ^/a/theatre$  
RewriteRule ^/?a/(.*)$ http://www.abc.com/a/$1 [R=301,L] 

RewriteCond %{HTTP_HOST} ^www.abc.com$ [NC]  
RewriteCond %{REQUEST_URI} !^/a/theatre  
RewriteRule ^/?a/(.*)$ http://www.xyz.com/a/$1 [NC,L,R=301] 
+0

빠른 답장을 보내 주셔서 감사합니다. Jon. 두 규칙 모두에서^/? a /를 추가했지만 둘 다 작동하지 않습니다. –

+0

@AmbrishDave는 문서 루트에없는 htaccess 파일의 이러한 규칙입니까? –

+0

이것은 htaccess 파일에 있으며이 파일은 "a"폴더에 있습니다. –

관련 문제