如何将子域重定向到不同的域?

发布于 2024-10-06 17:46:31 字数 211 浏览 0 评论 0原文

如何将

www.sub.example.com

重定向到:

www.example2.com

这是如何完成的 - 301? .htaccess?有人可以指出我正确的方向吗?我的主机是 NearlyFreeSpeech,我想要重定向到的域是一个具有静态 IP 的相当大的站点。

How do I redirect this:

www.sub.example.com

to this:

www.example2.com

How is this done -- 301? .htaccess? Can someone point me in the right direction please? My host is NearlyFreeSpeech and the domain I want to redirect to is quite a large site with a static IP.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

美人骨 2024-10-13 17:46:31

有多种方法可以执行此操作:

其他解决方案也是可能的,并且通常因服务器和配置堆栈而异。鉴于问题陈述中存在 .htaccess,我假设 Apache 符合规定。

这是有关通过 3xx 系列 HTTP 状态代码进行重定向的 Wikipedia 参考,(如果有人知道的话)对客户的观点感到好奇。

There are multiple ways to do this:

Other solutions are possible, and generally vary by server and configuration stack. I assume Apache compliance, given the presence of .htaccess in the problem statement.

Here's a Wikipedia reference on redirects via the 3xx family of HTTP status codes, if anyone's curious about the client's perspective.

埋葬我深情 2024-10-13 17:46:31

像这样的事情应该可以做到

RedirectPermanent / http://www.example2.com

RedirectPermanent会返回301代码并强制客户端转到www.example2.com,它在apache配置文件和.htaccess文件中工作。您需要启用 mod_alias 才能使用它。

您可以在 .htaccess 文件中的子域根目录或 apache 配置文件的 virtualhost 部分中使用它。

供您参考文档

Something like this should do it

RedirectPermanent / http://www.example2.com

RedirectPermanent would return a 301 code and force the client to go to www.example2.com, it works in apache config file and .htaccess file. You need mod_alias enabled to use it.

You can use this on the root directory of the subdomain in a .htaccess file, or in the virtualhost section of your apache configuration file.

For your reference the documentation

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文