Apache 正在从特定于语言的域重定向到以domain.com/en结尾的主域

Apache 正在从特定于语言的域重定向到以domain.com/en结尾的主域,apache,.htaccess,mod-rewrite,apache2,Apache,.htaccess,Mod Rewrite,Apache2,我有七个域,我想用适当的语言结尾重定向到我的主域: 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->do-main.eu 以下是我尝试过的: <IfModule mod_rewrite.c> Re

我有七个域,我想用适当的语言结尾重定向到我的主域:

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

重新启动发动机
RewriteCond%{HTTP_HOST}\.cz$[NC]
重写规则^(.*)$https://do-main.eu/cz [L,R=301]
重写cond%{HTTP_HOST}\(at|de)$[NC]
重写规则^(.*)$https://do-main.eu/de [L,R=301]
RewriteCond%{HTTP_HOST}\.sk$[NC]
重写规则^(.*)$https://do-main.eu/sk [L,R=301]
RewriteCond%{HTTP_HOST}\.pl$[NC]
重写规则^(.*)$https://do-main.eu/pl [L,R=301]
RewriteCond%{HTTP_HOST}\.be$[NC]
重写规则^(.*)$https://do-main.eu/nl [L,R=301]
RewriteCond%{HTTP_HOST}^\.do main\.eu$[NC]
RewriteCond%{HTTP_HOST}^\.domain\.eu$[NC]
重写规则^(.*)$https://do-main.eu [L,R=301]
但它只适用于.de和.at域(domain.eu to 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,R=301,L]

RewriteCond %{HTTP_HOST} ^(do-main)(\.cz)$ [NC]
RewriteRule ^ https://%1.eu/cs%{REQUEST_URI} [NE,R=301,L]

RewriteCond %{HTTP_HOST} ^(do-main)(\.sk|pl)$ [NC]
RewriteRule ^ https://%1.eu/%2%{REQUEST_URI} [NE,R=301,L]

RewriteCond %{HTTP_HOST} ^(do-main)(\.be)$ [NC]
RewriteRule ^ https://%1.eu/nl%{REQUEST_URI} [NE,R=301,L]

</IfModule>

重新启动发动机
RewriteCond%{HTTP_HOST}^domain\.eu$[NC]
重写规则^https://%do main.eu%{REQUEST_URI}[NE,R=301,L]
RewriteCond%{HTTP\u HOST}^(do main)(\.de|at)$[NC]
重写规则^https://%1.eu/%2%{REQUEST_URI}[NE,R=301,L]
RewriteCond%{HTTP\u HOST}^(do main)(\.cz)$[NC]
重写规则^https://%1.eu/cs%{REQUEST_URI}[NE,R=301,L]
RewriteCond%{HTTP\u HOST}^(do main)(\.sk|pl)$[NC]
重写规则^https://%1.eu/%2%{REQUEST_URI}[NE,R=301,L]
RewriteCond%{HTTP\u HOST}^(do main)(\.be)$[NC]
重写规则^https://%1.eu/nl%{REQUEST_URI}[NE,R=301,L]

这些域是否指向您的文档根目录?