如何更改所有子域以从各自的子目录中读取不同的内容?
我已将 DNS 配置为接受任何子域(通配符 *),但在将所需内容反馈给浏览器时遇到问题。
我希望每个子域返回相对内容,该内容驻留在我的服务器的 public_html
路径内的同名子目录中。
例如, example.domain.com/picture.jpg 实际上会请求 public_html/example/picture.jpg 处的文件
目前我已经测试了以下 .htaccess 代码,但它不起作用:
RewriteCond %{HTTP_HOST} ^(.*)\.domain\.com$ [NC]
RewriteRule ^(.*)$ %1/$1 [L]
此代码和类似的测试可以很好地基于子域 (%1) 进行重定向,但请求字符串 ($1) 似乎是问题所在。
I have my DNS configured to accept any subdomain (wildcard *), but I am having trouble feeding back the required content to the browsers.
I would like each subdomain to return the relative content, which resides in subdirectories of the same name within the public_html
path of my server.
eg, example.domain.com/picture.jpg
would actually request the file at public_html/example/picture.jpg
Currently I have tested the followed .htaccess code, but it is not functional:
RewriteCond %{HTTP_HOST} ^(.*)\.domain\.com$ [NC]
RewriteRule ^(.*)$ %1/$1 [L]
This code, and similar tests, can redirect based on the subdomain (%1) fine, but the request string ($1) seems to be the issue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许您可以看一下 mod_vhost_alias 模块:
http://httpd.apache。 org/docs/2.0/mod/mod_vhost_alias.html
Maybe you could take a look at the mod_vhost_alias module :
http://httpd.apache.org/docs/2.0/mod/mod_vhost_alias.html
尝试以下操作:
我没有测试这个,但我使用类似的代理规则:
Try the following:
I didn't test this one but I use similar rules for proxying: