如何解决从特定于语言的域重定向到以 domain.com/en 结尾的主域
do-main.de -> do-main.eu/de
do-main.at -> do-main.eu/de
do-main.cz -> do-main.eu/cs
do-main.sk -> do-main.eu/sk
do-main.pl -> do-main.eu/pl
do-main.be -> do-main.eu/nl
最后
domain.eu -> 域 main.eu
这是我尝试过的:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} \.cz$ [NC]
RewriteRule ^(.*)$ https://do-main.eu/cz [L,R=301]
RewriteCond %{HTTP_HOST} \.(at|de)$ [NC]
RewriteRule ^(.*)$ https://do-main.eu/de [L,R=301]
RewriteCond %{HTTP_HOST} \.sk$ [NC]
RewriteRule ^(.*)$ https://do-main.eu/sk [L,R=301]
RewriteCond %{HTTP_HOST} \.pl$ [NC]
RewriteRule ^(.*)$ https://do-main.eu/pl [L,R=301]
RewriteCond %{HTTP_HOST} \.be$ [NC]
RewriteRule ^(.*)$ https://do-main.eu/nl [L,R=301]
RewriteCond %{HTTP_HOST} ^\.do-main\.eu$ [NC]
RewriteCond %{HTTP_HOST} ^\.domain\.eu$ [NC]
RewriteRule ^(.*)$ https://do-main.eu [L,R=301]
</IfModule>
但它仅适用于 .de 和 .at 域(domain.eu 到 do-main.eu 也适用)。
有人可以帮我吗?
解决方法
您可以拥有以下 .htaccess 规则文件。请确保您的子域可用并且它们指向相同的文档根目录。
<IfModule mod_rewrite.c>
RewriteEngine ON
RewriteCond %{HTTP_HOST} ^domain\.eu$ [NC]
RewriteRule ^ https://%do-main.eu%{REQUEST_URI} [NE,R=301,L]
RewriteCond %{HTTP_HOST} ^(do-main)(\.de|at)$ [NC]
RewriteRule ^ https://%1.eu/%2%{REQUEST_URI} [NE,L]
RewriteCond %{HTTP_HOST} ^(do-main)(\.cz)$ [NC]
RewriteRule ^ https://%1.eu/cs%{REQUEST_URI} [NE,L]
RewriteCond %{HTTP_HOST} ^(do-main)(\.sk|pl)$ [NC]
RewriteRule ^ https://%1.eu/%2%{REQUEST_URI} [NE,L]
RewriteCond %{HTTP_HOST} ^(do-main)(\.be)$ [NC]
RewriteRule ^ https://%1.eu/nl%{REQUEST_URI} [NE,L]
</IfModule>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。