Set Apache headers conditionally

前端 未结 2 1639
梦谈多话
梦谈多话 2020-12-16 00:29

I\'m working with an apache server, and I\'d like to add headers conditionally.

If the URI matches a certain regex, I\'d like to add the header Access-Control-

相关标签:
2条回答
  • 2020-12-16 01:10

    This should also work (mod_rewrite is required):

    RewriteRule ^/en/foo.*$ - [ENV=SET_ACAO:true]
    Header set "Access-Control-Allow-Origin" "*" env=SET_ACAO
    

    where ^/en/foo.*$ a regex which is matched against request URL

    0 讨论(0)
  • 2020-12-16 01:11
    SetEnvIf Request_URI somepartofurl SIGN
    Header always add "Access-Control-Allow-Origin" "*" env=SIGN
    

    but this works only if located in the configuration. Placing it into .htaccess won't help.

    0 讨论(0)
提交回复
热议问题