.htaccess将子域重定向到外部URL [英] .htaccess Redirect Subdomain to External URL

查看:76
本文介绍了.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]

这篇关于.htaccess将子域重定向到外部URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆