使用 mod_rewrite 将二级域映射到子目录 [英] Mapping a secondary domain to a subdirectory using mod_rewrite

查看:35
本文介绍了使用 mod_rewrite 将二级域映射到子目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望将辅助域映射到文档根目录上的子文件夹.

I am looking to map a secondary domain to a subfolder on my document root.

例如,如果对域 www.example.com 的请求映射到我的 DocumentToot,则对 www.exampletwo.com 的请求转到 /sites/files/.

For example, if requests to the domain www.example.com map to my DocumentToot, then requests to www.exampletwo.com go to /sites/files/.

我无法在制作时完成从 www.exampletwo.com/index.htmlwww.exampletwo.com/sites/files/index.html 的重定向URL 仍然显示 www.exampletwo.com/index.html.有什么想法吗?

I am unable to accomplish a redirect from www.exampletwo.com/index.html to www.exampletwo.com/sites/files/index.html while making the URL still display www.exampletwo.com/index.html. Any ideas?

推荐答案

我相信您正在寻找这样的东西:

I believe you're looking for something like this:

RewriteCond %{HTTP_HOST} ^(www\.)?exampletwo\.com [NC]
RewriteRule ^/(.*) /sites/files/$1 [L]

这篇关于使用 mod_rewrite 将二级域映射到子目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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