如何将 onr 域(使用本地文件夹语言)重定向到两个域?
How to redirect onr domain (with local folder language) to two domains?
我有域名:
exa.mple -> 荷兰语版本
exa.mple/en -> 英文版本
现在我有
example.nl
example.com
我想将所有网址从 exa.mple/en 重定向到 example.com/$
而 exa.mple 到 example.nl
我有这个代码:
#exa.mple/en to .com
RewriteCond %{HTTP_HOST} ^exa.mple/en$ [OR]
RewriteCond %{HTTP_HOST} ^www.exa.mple/en$
RewriteRule (.*)$ "https://example.com/" [R=301,L]
#exa.mple to .nl
RewriteCond %{HTTP_HOST} ^exa.mple$ [OR]
RewriteCond %{HTTP_HOST} ^www.exa.mple$
RewriteRule (.*)$ "https://example.nl/" [R=301,L]
但是如果我有这个网站就会有问题:
然后我得到:
https://example.nl/en/contact
如果 URL 包含 /en/ 重定向到 NL 域,有人可以帮助我如何避免?
你可以使用这个:
RewriteEngine on
#ex.mple.com/en to .com
RewriteCond ℅{HTTP_HOST} ^exa.mple$
RewriteRule ^en.*$ http://example.com%{REQUEST_URI} [L,NE,R=301]
#exa.mple.com/ to .nl
RewriteCond ℅{HTTP_HOST} ^exa.mple$
RewriteRule ^.*$ http://example.nl%{REQUEST_URI} [L,NE,R=301]
第二条规则将所有请求从 exa.pmle
重定向到 example.nl
。如果您只想重定向主页,则只需将正则表达式模式更改为 ^$
.
确保在测试这些新规则之前清除浏览器缓存。
我创建了这段代码,一切正常:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^en/(.*)$ https://example.com/ [R=301,L]
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^exa.mple$
RewriteRule ^(?!en)(.*)$ https://example.nl/ [R=301,L]
我有域名:
exa.mple -> 荷兰语版本 exa.mple/en -> 英文版本
现在我有
example.nl example.com
我想将所有网址从 exa.mple/en 重定向到 example.com/$ 而 exa.mple 到 example.nl
我有这个代码:
#exa.mple/en to .com
RewriteCond %{HTTP_HOST} ^exa.mple/en$ [OR]
RewriteCond %{HTTP_HOST} ^www.exa.mple/en$
RewriteRule (.*)$ "https://example.com/" [R=301,L]
#exa.mple to .nl
RewriteCond %{HTTP_HOST} ^exa.mple$ [OR]
RewriteCond %{HTTP_HOST} ^www.exa.mple$
RewriteRule (.*)$ "https://example.nl/" [R=301,L]
但是如果我有这个网站就会有问题:
然后我得到: https://example.nl/en/contact
如果 URL 包含 /en/ 重定向到 NL 域,有人可以帮助我如何避免?
你可以使用这个:
RewriteEngine on
#ex.mple.com/en to .com
RewriteCond ℅{HTTP_HOST} ^exa.mple$
RewriteRule ^en.*$ http://example.com%{REQUEST_URI} [L,NE,R=301]
#exa.mple.com/ to .nl
RewriteCond ℅{HTTP_HOST} ^exa.mple$
RewriteRule ^.*$ http://example.nl%{REQUEST_URI} [L,NE,R=301]
第二条规则将所有请求从 exa.pmle
重定向到 example.nl
。如果您只想重定向主页,则只需将正则表达式模式更改为 ^$
.
确保在测试这些新规则之前清除浏览器缓存。
我创建了这段代码,一切正常:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^en/(.*)$ https://example.com/ [R=301,L]
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^exa.mple$
RewriteRule ^(?!en)(.*)$ https://example.nl/ [R=301,L]