2013-10-07 2 views
0

Drupal 7에서 하나의 노드를 자체 도메인이있는 방문 페이지로 사용하고 싶습니다.하나의 단일 노드를 다른 도메인으로 다시 작성

두 도메인이 동일한 폴더에 연결되어있어 동일한 콘텐츠를 보여줍니다.

www.domainA.com/landingpage는해야 www.domainB.com - 아무것도 없습니다 ...

RewriteCond %{HTTP_HOST} ^(www.)?domainA.com$ 
RewriteRule ^landingpage http://www.domainB.com [R=301,L] 

그리고 내가 가 domainB.comDOMAINB의 내용을 표시 할 .COM/landingpage :

RewriteCond %{HTTP_HOST} ^(www.)?domainB.com$ 
RewriteRule ^$ /landingpage [P] 

이 작동합니다.이 www.domainA.com/allotherpages

RewriteCond %{ENV:REDIRECT_STATUS} ^$ 
RewriteCond %{REQUEST_URI} !^/landingpage$ [NC] 
RewriteCond %{HTTP_HOST} ^(www\.)?domainB\.com$ 
RewriteRule^http://www.domainA.com [R=301,L] 
해야 www.domainB.com/allotherpages :

는 지금은 중복 내용을 피하기 위해 DOMAINB에서 다시 도메인 A에 대한 모든 다른 페이지로 리디렉션해야합니다

<IfModule mod_rewrite.c> 
RewriteEngine on 

RewriteRule^- [E=protossl] 
RewriteCond %{HTTPS} on 
RewriteRule^- [E=protossl:s] 

RewriteRule^- [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 

RewriteRule "(^|/)\." - [F] 

RewriteBase/



# HERE STARTS MY CUSTOM RULE-SET: 

# Rewrite one node to new Domain: 
RewriteCond %{HTTP_HOST} ^(www.)?domainA.com$ 
RewriteRule ^landingpage http://www.domainB.com [R=301,L] 

# Front page of domainB shows content of one node: 
RewriteCond %{HTTP_HOST} ^(www.)?domainB.com$ 
RewriteRule ^$ /landingpage [P] 

# Rewrite all other pages from domainB.com to main domainA.com: 
RewriteCond %{ENV:REDIRECT_STATUS} ^$ 
RewriteCond %{REQUEST_URI} !^/landingpage$ [NC] 
RewriteCond %{HTTP_HOST} ^(www\.)?domainB\.com$ 
RewriteRule^http://www.domainA.com [R=301,L] 

# HERE ENDS MY CUSTOM RULE-SET 



<IfModule mod_headers.c> 
    # Serve gzip compressed CSS files if they exist and the client accepts gzip. 
    RewriteCond %{HTTP:Accept-encoding} gzip 
    RewriteCond %{REQUEST_FILENAME}\.gz -s 
    RewriteRule ^(.*)\.css $1\.css\.gz [QSA] 

    # Serve gzip compressed JS files if they exist and the client accepts gzip. 
    RewriteCond %{HTTP:Accept-encoding} gzip 
    RewriteCond %{REQUEST_FILENAME}\.gz -s 
    RewriteRule ^(.*)\.js $1\.js\.gz [QSA] 

    # Serve correct content types, and prevent mod_deflate double gzip. 
    RewriteRule \.css\.gz$ - [T=text/css,E=no-gzip:1] 
    RewriteRule \.js\.gz$ - [T=text/javascript,E=no-gzip:1] 

    <FilesMatch "(\.js\.gz|\.css\.gz)$"> 
     # Serve correct encoding type. 
     Header set Content-Encoding gzip 
     # Force proxies to cache gzipped & non-gzipped css/js files separately. 
     Header append Vary Accept-Encoding 
    </FilesMatch> 
</IfModule> 
</IfModule> 

"는 가짜 진주 목걸 작동 : 그것은 Alltogether

은 (드루팔 7의 htaccess로 파일의 일부)입니다 (CSS 파일)을 모두 다시 쓰기 때문에 레이아웃과 모든 것을 망가뜨릴 수 있습니다.

해결 방법을 찾을 수 없습니다.

편집 : 감사합니다. 덕분에 Jon Lin!

RewriteCond %{HTTP_HOST} ^(www.)?domainA\.com$ 
RewriteRule ^landingpage http://www.domainB.com/ [R=301,L] 

RewriteCond %{HTTP_HOST} ^(www.)?www.domainB\.de$ 
RewriteRule ^$ /landingpage [P] 

RewriteCond %{ENV:REDIRECT_STATUS} ^$ 
RewriteCond %{REQUEST_URI} !\.(css|js|png|svg|ico|jpg)$ [NC] 
RewriteCond %{REQUEST_URI} !^/$ 
RewriteCond %{REQUEST_URI} !^/landingpage$ [NC] 
RewriteCond %{HTTP_HOST} ^(www\.)?www.domainB\.de$ 
RewriteRule ^(.*)$ http://www.domainA.com/$1 [R=301,L] 

답변

0

먼저 나는 P 플래그가 필요하다고 생각하지 않습니다. 두 도메인이 같은 장소를 가리 때문에, 당신은 프록시 요청이 필요하지 않습니다 : 다른 모든 것들에 대한

RewriteCond %{HTTP_HOST} ^(www.)?domainB.com$ 
RewriteRule ^$ /landingpage [L] 

을, 당신은 요청을 캡처해야하고 등이 리디렉션의 일부로 :

RewriteCond %{REQUEST_URI} !^/$ 
RewriteCond %{REQUEST_URI} !^/landingpage$ [NC] 
RewriteCond %{HTTP_HOST} ^(www\.)?domainB\.com$ 
RewriteRule ^(.*)$ http://www.domainA.com/$1 [R=301,L] 

이 크게 리디렉션되는 CSS와 스크립트를 방지하려는 경우, www.domainA.com

의 방문 페이지 모든을 리디렉션되기 전에 당신이 그들을 제외 할 추가 조건을 추가 할 수 있습니다 :

RewriteCond %{REQUEST_URI} !\.(css|js)$ [NC] 
RewriteCond %{REQUEST_URI} !^/$ 
RewriteCond %{REQUEST_URI} !^/landingpage$ [NC] 
RewriteCond %{HTTP_HOST} ^(www\.)?domainB\.com$ 
RewriteRule ^(.*)$ http://www.domainA.com/$1 [R=301,L] 
+0

P- 플래그를 변경하려고 시도했지만 필요로하는 것 같습니다. 그리고 RewriteCond % {ENV : REDIRECT_STATUS}도 마찬가지입니다. 위의 변경된 규칙 게시 - 작동하는 것 같습니다 : 도와 줘서 고마워! – tFranz

관련 문제