将相同的 mod_rewrite 规则应用于许多虚拟主机的最简单方法?
我有很多很多的虚拟主机来支持很多很多的客户端域。我想向我的核心应用程序添加一项功能,该功能需要将几个 mod_rewrite 规则应用于所有这些域。到目前为止,我最好的方法是将规则添加到我的全局 httpd.conf 中,并将这两行添加到每个虚拟主机中:
RewriteEngine On
RewriteOptions Inherit
但显然,无需编辑每个虚拟主机即可完成此操作。有没有办法让我的 mod_rewrite 规则适用于所有虚拟主机而不需要编辑它们?
I have lots and lots of virtualhosts to support lots and lots of client domains. I want to add a feature to my core app that requires a couple mod_rewrite rules to be applied to ALL those domains. Best approach I have so far is to add the rules to my global httpd.conf, and add these two lines to every single virtualhost:
RewriteEngine On
RewriteOptions Inherit
But it would obviously be preferable to accomplish this without having to edit every virtualhost. Is there any way to make my mod_rewrite rules apply to all virtualhosts without editing them?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,这可能不适用于您,但如果您有很多虚拟主机,并且所有这些虚拟主机共享共同的内容,您可以使用 mod_rewrite 进行虚拟主机并且只有一个文件:
搜索“ >海量虚拟主机”在本文档中,您可以阅读这个以获取更详细的示例(从最简单的示例到最详细的示例)一个带有映射域和文档根的文件)。
如果您在某些虚拟主机上有一些非常具体的配置,则无法在此系统中处理它们,但如果您可以按类型对处理的域进行分组(每种类型具有相同的配置),则可以使用此系统。
关于“最简单”的方式,这可能不是最简单的,因为它确实需要很大的改变和测试。但如果您正在管理克隆,那么在这些更改之后,系统将变得更加简单。
Well, this may not apply to you, but if you have a lot of virtualhosts and that all theses virtualhosts share common things you could use mod_rewrite to do the virtualhosting and have only one file:
Search "Mass Virtual Hosting" in this document and you can read this one for more detailled examples (going from the simpliest one to the one with a file mapping domains and document roots).
If you have some very specific configurations on some VirtualHosts you cannot handle them in this system, but if you can group your handled domains by types (with identical configurations for each type) you can use this system.
About the 'simpliest' way, this is maybe not the simpliest as it really need big changes and tests. But it will be really a simplier system after these changes if you are managing clones.