IfModule:什么时候需要指定它?
您是否需要将重写规则包含在以下内容中?
<IfModule mod_rewrite.c>
# Rewrite rules here.
</IfModule>
假设 mod_rewrite 没有打开,规则就不会被执行,不是吗?
Do you need to enclose your rewrite rules with the following?
<IfModule mod_rewrite.c>
# Rewrite rules here.
</IfModule>
Assuming mod_rewrite wasn't turned on, the rules won't be executed anyway, no?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果 mod_rewrite 未打开,规则将在启动时生成错误。
每当有理由不确定模块是否已加载(例如,在多个服务器上使用“通用”.htaccess)时,IfModule 标记就很有用。如果您确定模块已加载,则不需要标签。
If mod_rewrite wasn't turned on, the rules would generate an error upon starting.
Whenever there's reason NOT to be sure a module is loaded ("generic" .htaccess used on multiple servers for example), the IfModule tags are useful. If you're sure the module is loaded, there's no need for the tags.
来自 Apache 文档 ifmodule:仅当您需要配置文件无论是否安装某些模块都可以工作时,才应使用此指令。它不应该用来包含您想要一直工作的指令,因为它可以抑制有关丢失模块的有用错误消息。
From the Apache docs ifmodule: This directive should only be used if you need your configuration file to work whether or not certain modules are installed. It should not be used to enclose directives that you want to work all the time, because it can suppress useful error messages about missing modules.