【发布时间】:2016-07-18 18:27:18
【问题描述】:
我有多个以 .nl .com 和 .de 结尾的域。对于每个域名,我都有不同的语言。我的文件位于 .nl 域中。我想要的是所有域的以下内容:
- 将 http://* 重定向到 https://*
- 将http://example.* 重定向到https://www.example.*
- 我将文件放在 1 台服务器上,并希望它们看起来像在 3 台服务器上。
这是我在主服务器上的 (.NL)
RewriteCond %{HTTP_HOST} !www.example.nl$ [NC]
RewriteRule ^(.*)$ https://www.example.nl/$1 [L,R=301]
这适用于 .DE
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://www.example.de/$1 [L,R=301]
RewriteCond %{HTTP_HOST} !www.example.de$ [NC]
RewriteRule ^(.*)$ http://www.example.de/$1 [L,R=301]
RewriteRule ^(.*)$ http://www.example.nl/$1 [P]
这适用于 .COM
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301]
RewriteCond %{HTTP_HOST} !www.example.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
RewriteRule ^(.*)$ http://www.example.nl/$1 [P]
我已经尝试了所有方法,但我无法弄清楚。
【问题讨论】:
-
先将所有请求重写为https,这样更容易。由于所有内容都将访问 www.example.com,因此只需设置使用 [OR] 的规则: RewriteRule ^(.*)$ example.com/$1 [OR] RewriteRule ^(.*)$ example.de/$1 。我不熟悉 [P] 代理服务器,但您似乎没有重定向到代理服务器,只是重定向到 .nl 域,标准 301
标签: apache .htaccess mod-rewrite