【问题标题】:Combine Apache commands in .htaccess在 .htaccess 中组合 Apache 命令
【发布时间】:2018-03-07 19:38:28
【问题描述】:

如果我想在 Apache 服务器上拒绝访问两个文件 - 有没有办法将它们组合起来,而不是编写两次相同的代码(或者对其他文件也编写更多次)?

阿帕奇

<files wp-config.php>
order allow,deny
deny from all
</files>

<Files xmlrpc.php>
Order Deny,Allow
Deny from all
</Files>

【问题讨论】:

    标签: apache .htaccess file server


    【解决方案1】:

    对于多个文件,请像这样使用FilesMatch

    <filesMatch "wp-config(\.php)?|xmlrpc(\.php)?">
    order allow,deny
    deny from all
    </filesMatch>
    

    这将匹配wp-config.php or wp-configxmlrpc.php or xmlrpc 是否带有扩展名

    【讨论】:

    • 嗨@MohammedElhag,感谢您的回答。如果我只想要包含 .php 的版本,我会做这样的开始标签:
    • 刚刚得到?像这样
    • 很高兴为您提供帮助,谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-10-09
    • 2022-01-07
    • 2014-08-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-01
    相关资源
    最近更新 更多