Detect Apache version in apache config?

后端 未结 5 495
醉酒成梦
醉酒成梦 2020-12-30 00:48

tl;dr: How do I do the following in a .conf or .htaccess file:


  # Do A


  # Do B
&         


        
5条回答
  •  情歌与酒
    2020-12-30 01:25

    I ran into this problem because FallbackResource is not in early versions of Apache and often clever hosting companies remove mod_rewrite once they have a version of Apache with FallbackResource. I use the following .htaccess when I want to put library code up that adapts to its environment:

    
        RewriteEngine on
        RewriteRule ^ - [E=protossl]
        RewriteCond %{HTTPS} on
        RewriteRule ^ - [E=protossl:s]
        RewriteRule "(^|/)\." - [F]
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_URI} !=/favicon.ico
        RewriteRule ^ index.php [L]
    
    
    
        FallbackResource index.php
    
    

    Now of course there are some Apache versions / setups where this fails - but if mod_rewrite is there, use it and if not, hope that FallbackResource is there.

提交回复
热议问题