如何使用root .htaccess文件重定向子域?

发布于 2025-01-18 22:33:07 字数 216 浏览 5 评论 0原文

我的目标是编辑域的.htaccess文件,例如 example.com ,添加各种URL重定向,以便:

  • apple.example.com to example.org/subdomain1
  • pear 。

​同样,我只想编辑root .htaccess文件。谢谢!

My goal is to edit the .htaccess file of a domain, for example, example.com, to add a variety of URL redirects such that:

  • apple.example.com goes to example.org/subdomain1
  • pear.example.com goes to example.org/subdomain2
  • strawberry.example.com goes to example.org/subdomain3
  • banana.example.com goes to example.org/subdomain4

How would I do this? Again, I only want to edit the root .htaccess file. Thanks!

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

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

发布评论

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

评论(1

若言繁花未落 2025-01-25 22:33:07

使用mod_rewrite:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^apple\.example\.com [NC]
RewriteRule ^$ https://example.org/subdomain1 [R=302,L]

上述重定向https://apple.example.com/ https://example.org/subdomain1根据您的第一个示例。

等。


参考

Using mod_rewrite:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^apple\.example\.com [NC]
RewriteRule ^$ https://example.org/subdomain1 [R=302,L]

The above redirects https://apple.example.com/ to https://example.org/subdomain1 as per your first example.

Etc.


Reference

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