2013-10-07 29 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.com顯示域B的含量.com/landingpage

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

This works。

現在我需要重定向所有其他網頁從域B回DOMAINA避免重複的內容www.domainB.com/allotherpages應該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] 

產品總數是(Drupal 7的的htaccess的文件的一部分):

<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> 

「作品一個littl e位「 - 但打破布局和一切 - 我認爲,因爲它重寫了其他所有內容(CSS文件),...

找不到解決方案。

編輯: 這似乎工作 - 感謝喬恩林

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] 

之前,你被重定向一切www.domainA.com

着陸頁如果要徹底防止CSS和腳本被重定向,您可以添加其他條件,排除它們:

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

相關問題