I finally found the answer in the CDN module. As the name implies, this is intended to be used with content delivery networks but essentially all it does is a rule-based re-writing of the URLs that Drupal outputs. I've used it to re-write URLs so that different file types can be served from unique hostnames (again, to maximize parallel downloads).
reading your question again, I think that you want your code to always return subdomain1.localhost, and you want apache to somehow change this to subdomain1.example.com on your production server.
You could do this with ProxyPassReverse, although you might have to run two copies of Apache if the subdomain1 is on the same machine. (I don't know if Apache will cope with talking to itself here). This is an expensive solution.
Instead, I recommend your parameterize your code. On rails stacks, the easiest way to do this with the production.rb cp that capistrano recommends, and you might want to investigate similar ways of deploying your PHP code.
发布评论
评论(2)
终于在CDN模块中找到了答案。顾名思义,它旨在与内容交付网络一起使用,但本质上它所做的只是基于规则重写 Drupal 输出的 URL。我用它来重写 URL,以便可以通过唯一的主机名提供不同的文件类型(同样,为了最大限度地提高并行下载)。
I finally found the answer in the CDN module. As the name implies, this is intended to be used with content delivery networks but essentially all it does is a rule-based re-writing of the URLs that Drupal outputs. I've used it to re-write URLs so that different file types can be served from unique hostnames (again, to maximize parallel downloads).
再次阅读您的问题,我认为您希望代码始终返回 subdomain1.localhost,并且您希望 apache 以某种方式将其更改为生产服务器上的 subdomain1.example.com 。
您可以使用 ProxyPassReverse 来完成此操作,但如果 subdomain1 位于同一台计算机上,您可能必须运行两个 Apache 副本。 (我不知道 Apache 是否能够处理这里的自言自语)。这是一个昂贵的解决方案。
相反,我建议您对代码进行参数化。
在 Rails 堆栈上,最简单的方法是使用 capistrano 推荐的 production.rb cp,并且您可能想要研究部署 PHP 代码的类似方法。
reading your question again, I think that you want your code to always return subdomain1.localhost, and you want apache to somehow change this to subdomain1.example.com on your production server.
You could do this with ProxyPassReverse, although you might have to run two copies of Apache if the subdomain1 is on the same machine. (I don't know if Apache will cope with talking to itself here). This is an expensive solution.
Instead, I recommend your parameterize your code.
On rails stacks, the easiest way to do this with the production.rb cp that capistrano recommends, and you might want to investigate similar ways of deploying your PHP code.