V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
slince
V2EX  ›  程序员

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

  •  
  •   slince · Dec 25, 2016 · 2326 views
    This topic created in 3412 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   ·   1494 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 16:51 · PVG 00:51 · LAX 09:51 · JFK 12:51
    ♥ Do have faith in what you're doing.