使用 .htacces 屏蔽 URL,使子域成为根域

发布于 2024-11-16 01:25:24 字数 688 浏览 3 评论 0原文

我目前有一个在子目录中构建微型网站的 cms。所以主站点是根目录,每个子站点都位于子目录中。

例如 root = www.mainsite.org

microsite = www.mainsite.org/microsite

我目前正在主站点的托管空间上购买和停放域名。我已将其设置为当用户输入 www.microsite.org 时,他们会使用 htaccess 中的以下内容重定向到 www.mainsite.org/microsite

RewriteCond %{HTTP_HOST} ^microsite.org$ [OR]
RewriteCond %{HTTP_HOST} ^microsite.org$
RewriteRule ^/?$ "http\:\/\/mainsite\.org\/microsite" [R=301,L]

我也可以屏蔽 url,以便显示 www.mainsite.com/microsite在网址栏中显示为 www.microsite.org - 允许每个微型网站保留个人身份。我拥有每个微型网站的域,

我不一定需要一揽子规则,我很乐意为每个微型网站添加新代码。

顺便说一句,我不太了解 htaccess 编辑 - 我对此很陌生,所以具体的答案将不胜感激。我已经寻找答案,但我认为我没有找到任何以这种方式掩盖根目录的答案 - 大多数似乎都隐藏了子目录。

谢谢

I currently have a cms which builds microsites in subdirectories. So the mainsite is the root and each subsite is in a subdirectory.

eg root = www.mainsite.org

microsite = www.mainsite.org/microsite

I'm currently buying and parking domains on the mainsite's hosting space. I have it set up so that when the user types in www.microsite.org they are redirected to www.mainsite.org/microsite using the following in my htaccess

RewriteCond %{HTTP_HOST} ^microsite.org$ [OR]
RewriteCond %{HTTP_HOST} ^microsite.org$
RewriteRule ^/?$ "http\:\/\/mainsite\.org\/microsite" [R=301,L]

can I also mask the url so that www.mainsite.com/microsite appears in the url bar as www.microsite.org - allowing each of the microsites to retain individual identity. I own the domains for each of the microsites

I don't necessarily need a blanket rule, I'm happy to add new code for each microsite.

By the way, I don't really understand htaccess editing - am pretty new to it, so specific answers would be hugely appreciated. I've searched for answers, but don't think I've found any that are masking the root in this way - most seem to hide the subdirectories.

thanks

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文