• 请不要在回答技术问题时复制粘贴 AI 生成的内容
slince
V2EX  ›  程序员

apache 重写规则带多个条件时出现问题

  •  
  •   slince · Dec 25, 2016 · 2367 views
    This topic created in 3432 days ago, the information mentioned may be changed or developed.
    <IfModule mod_rewrite.c>
        RewriteEngine On
        #img 域名下只能访问图片
        RewriteCond %{REQUEST_FILENAME} !^.*\.(jpg|png|jpeg|gif) [NC]
        RewriteCond %{HTTP_HOST} ^img [NC]
        RewriteRule ^.*$ – [F,L]
    </IfModule>
    

    本意为当访问资源扩展名非图片扩展名并且访问的 host 是 img.xxx.xx 则阻止请求,但实际效果是当访问 url 为 img.xxx.xx 时皆为 403 ,不管第一个条件是否符合;条件 1 和条件 2 颠倒过来也是一样的效果

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3937 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 00:56 · PVG 08:56 · LAX 17:56 · JFK 20:56
    ♥ Do have faith in what you're doing.