我如何能实现在Apache的一个全球性的RewriteCond /重写规则适用于所有虚拟主机? [英] How can I implement a global RewriteCond / RewriteRule in Apache that applies to all virtual hosts?

查看:149
本文介绍了我如何能实现在Apache的一个全球性的RewriteCond /重写规则适用于所有虚拟主机?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

标题pretty多少说明了一切。 :-)我有很多的虚拟主机,我想提出一个重写块在那个网址重写无论哪个虚拟主机的请求可能被定向到httpd.conf文件的顶部。如何赫克我做到这一点?

The title pretty much says it all. :-) I have lots of virtual hosts and I want to put a single rewriting block at the top of the httpd.conf file that rewrites URLs no matter which virtual host the request might be directed to. How the heck do I do this?

我发现但我的问题是一样的:我怎么能做到这一点,而不诉诸.htaccess文件并为每一虚拟主机的其他一些行动?

I found this but my question is the same: how can I do this without resorting to .htaccess files and performing some other action for each virtual host?

OMGTIA!

推荐答案

指定 RewriteOptions InheritDown 父范围(如httpd.conf)中得到应用中的规则孩子没有虚拟主机他们对矫正

Specify RewriteOptions InheritDown in the parent scope (such as httpd.conf) to get your rules applied in child VHosts without modifing them.

Apache支持这一点,因为2.4.8(不提供原题的时间)。

Apache supports this since 2.4.8 (not available at the time of the original question).

从文件 RewriteOptions

InheritDown

如果启用此选项,所有子配置将继承当前配置的配置。它相当于在所有子配置指定RewriteOptions继承。如果要了解关于父子关系是如何处理的更多细节,继承选项。
  可在Apache HTTP服务器2.4.8及更高版本。

If this option is enabled, all child configurations will inherit the configuration of the current configuration. It is equivalent to specifying RewriteOptions Inherit in all child configurations. See the Inherit option for more details on how the parent-child relationships are handled. Available in Apache HTTP Server 2.4.8 and later.

InheritDownBefore

和上面一样InheritDown,但是从目前管理的原则在任何儿童的范围规定的规则之前被应用。
  可在Apache HTTP服务器2.4.8及更高版本。

Like InheritDown above, but the rules from the current scope are applied before rules specified in any child's scope. Available in Apache HTTP Server 2.4.8 and later.

IgnoreInherit

这个选项强制当前和儿童配置,忽略会从父指定InheritDown或InheritDownBefore继承的所有规则。
  可在Apache HTTP服务器2.4.8及更高版本。

This option forces the current and child configurations to ignore all rules that would be inherited from a parent specifying InheritDown or InheritDownBefore. Available in Apache HTTP Server 2.4.8 and later.

http://httpd.apache.org/docs/current /mod/mod_rewrite.html#rewriteoptions

这篇关于我如何能实现在Apache的一个全球性的RewriteCond /重写规则适用于所有虚拟主机?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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