.htaccess将子域重定向到外部URL

问题描述:

我们需要从主站点运行一些子域,我们需要将其指向处理所需管理员的外部站点。

We need to run a few subdomains from our main site and we need to point these to external sites that deal with the admin required.

我只需要重定向使用.htaccess的外部URL的子域,以及有关将其放在.htaccess文件中的位置的任何建议,例如就在顶部,因为我知道这会影响某些重写规则。

I simply need to redirect a subdomain to an external URL using .htaccess and also any advise about where to put it in the .htaccess file e.g. right at the top, as i know this effects certain rewrite rules.

我不会写我认为应该的内容,因为这只会导致答案沿着特定的路线。

I won't write what i think it should be as this just leads the answer down a specific route.

干杯,

真的很感激。

Dan

如果要将子域重定向到另一个域,则.htaccess中不应有其他内容

If you are redirecting a subdomain to another domain then there shouldn't be anything else in the .htaccess file other than this.

 # This will redirect a subdomain to another domain
 RewriteEngine On
 RewriteCond %{HTTP_HOST} ^yoursubdomain\.yourdomain\.com$ [NC]
 RewriteRule ^(.*) http://www.newdomain.com/$1 [L,R]