mod-rewrite - 使用 mod_rewrite 将辅助域映射到子目录

标签 mod-rewrite apache2 dns subdirectory

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

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

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

最佳答案

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

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

关于mod-rewrite - 使用 mod_rewrite 将辅助域映射到子目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4810846/

相关文章:

linux - 在 apache2 上安全地托管其他人

internet-explorer - 当同时请求时,下载的文件在 IE 中损坏

php - .htaccess 强制 'www.' 并将其余 url 正常附加到末尾

php - 在 Apache RewriteRule 指令中设置环境变量时,是什么导致变量名称以 "REDIRECT_"为前缀?

php - Htaccess 重写目录到文件

linux - 在 Linux 上为域名创建符号链接(symbolic link)

shell - 将主机名解析为 IP 地址的可移植方法

regex - 除非明确允许,否则如何配置 Apache 重写规则以将所有请求重定向到 404

mod-rewrite - mod_rewrite : why can't environment variables be used to prevent recursion?

用于更新 Bind9 DNS 的 C++ 程序