Drupal 7 の 1 つのノードを独自のドメインを持つランディング ページとして使用したいと考えています。
両方のドメインが同じフォルダーにリンクされており、同じコンテンツが表示されます。
www.domainA.com/landingpageはwww.domainB.comにする必要があります- 他には何もありません ...
RewriteCond %{HTTP_HOST} ^(www.)?domainA.com$
RewriteRule ^landingpage http://www.domainB.com [R=301,L]
そして、 domainB.comにdomainB.com/landingpageのコンテンツを表示させたい:
RewriteCond %{HTTP_HOST} ^(www.)?domainB.com$
RewriteRule ^$ /landingpage [P]
これは機能します。
コンテンツの重複を避けるために、他のすべてのページを domainB から 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-file の一部):
<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>
「少しは動く」 - しかし、レイアウトとすべてを壊します - 他のすべて (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]