【发布时间】:2019-12-16 03:32:43
【问题描述】:
我想将 subdomain.example.com 和子域访问的所有可能的 URL(如 subdomain.example.com/somefolder/somefile.php)重定向到另一个域 example-two.com。 htaccess 可以吗?
【问题讨论】:
标签: .htaccess subdomain addon-domain
我想将 subdomain.example.com 和子域访问的所有可能的 URL(如 subdomain.example.com/somefolder/somefile.php)重定向到另一个域 example-two.com。 htaccess 可以吗?
【问题讨论】:
标签: .htaccess subdomain addon-domain
对于将 subdomain.example.com/any-address 重定向到 example-two.com,请将此规则添加到您的 subdomain.example.com .htaccess 文件的顶部
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?subdomain\.example\.com [NC]
RewriteRule (.*) http://example-two.com/ [R=301,L]
</IfModule>
对于将 subdomain.example.com/any-address 重定向到 example-two.com/any-address 将此规则添加到您的 subdomain.example.com .htaccess 文件的顶部
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?subdomain\.example\.com [NC]
RewriteRule (.*) http://example-two.com/$1 [R=301,L]
</IfModule>
【讨论】: