简单的 .htaccess 子域重写

发布于 2024-10-02 12:35:18 字数 585 浏览 0 评论 0原文

我知道这里有很多关于此的问题......但现在我感觉就像一头被迎面而来的车灯惊呆的鹿......我只是不知道从哪里开始以及选择哪个选项。

我的要求很简单。

用户转到 http://application.domain.comhttp://www.application.domain.com 这些文件的真实位置是 http://www.domain.com/application

显然这需要使用通配符来完成,以便任何域(即使它不存在)触发重写。

我希望这对某人有意义

编辑: 我还应该提到我已将通配符 A 记录添加到 Cpanel *.domain.com 中的 DNS 条目

谢谢

Tim

I know there is a lot of questions on here about this... but right now I feel like a deer stunned by oncoming headlights... I just don't know where to start and which option to choose.

My requirements are simple.

User goes to http://application.domain.com or http://www.application.domain.com and the real location of these files is http://www.domain.com/application

Obviously this needs to be done using wildcards so that any domain (even if it doesn't exist) triggers the rewrite.

I hope this makes sense to someone

EDIT:
I should also mention I have added the wildcard A record to my DNS entries in Cpanel *.domain.com

Thanks

Tim

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

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

发布评论

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

评论(2

丿*梦醉红颜 2024-10-09 12:35:18

我将这个问题发布到 serverfault.com 上,icyrock 解决了它。如果其他人想知道这里给出的答案:

https://serverfault .com/questions/203780/troubleshooting-a-htaccess-wildcard-subdomain-rewrite/203804#203804

蒂姆

I posted this question onto serverfault.com and icyrock solved it. Incase anyone else is wondering the answer given is here:

https://serverfault.com/questions/203780/troubleshooting-a-htaccess-wildcard-subdomain-rewrite/203804#203804

Tim

野稚 2024-10-09 12:35:18

.htaccess 中最简单的方法是将以下内容放入 htaccess 文件中尽可能高的层次结构中。

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.application\.* [OR]
RewriteCond %{HTTP_HOST} ^application\.* [NC]
RewriteRule .* http://www.domain.com/application [L]

Simplest way in .htaccess would be to put the following in an htaccess file as high up in the hierarchy as possible.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.application\.* [OR]
RewriteCond %{HTTP_HOST} ^application\.* [NC]
RewriteRule .* http://www.domain.com/application [L]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文