且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

htaccess的子域名重定向问题

更新时间:2023-10-21 17:16:58

你可以访问你的Web服务器的配置?这是更好地配置Web服务器完成的。

Do you have access to your webserver configuration? This is better done by configuring the webserver.

在Apache将配置一个虚拟域这样的:

On apache you would configure one virtual domain like this:

<虚拟主机*:80>

        ServerName somedomainiwanttoredirect.com
        ServerAlias maybe.somemoredomainstoredirect.com
        ServerAlias orsubdomains.toredirect.com
        RewriteEngine On
        RewriteRule ^(.*)$ http://www.target.com/$1 [R=301,L]

< /虚拟主机>

和你的实际配置,www.target.com你添加子域,你不希望被重定向: ServerAlias​​ subdomain.target.com

and on your real configuration, the www.target.com you add your subdomains that you do not want to be redirected: ServerAlias subdomain.target.com