Domain name specific code blocks in htaccess

前端 未结 3 1275
醉话见心
醉话见心 2021-02-04 03:29

We have local servers, central dev, staging and production servers. However the dev and staging are password protected for obvious reasons. So after deploying any changes to the

3条回答
  •  孤城傲影
    2021-02-04 03:49

    I found a nice solution, to distinguish "localhost" vs. "live":

    Since the conditionals of htaccess are somewhat limited why not settle for IfModule?: Compare the modules you have (i.e. using , and look for a significant, hopefully long-term difference, e.g. if you develop on windows and deploy on linux mod_win32.c might be good. ( Don't forget to add the .c which phpinfo() ommits.)

    Then you can go about it like this (tested):

     
        RewriteRule ^banana$ test.php?dudeThisIsLocal=1
    
     
        RewriteRule ^banana$ test.php?dudeThisIsLive=1
    
    

    This example makes for a good sanity test, browing to yourdomain/banana resp. localhost/banana and if you (having rewrite enabled ) dump the $_GET array in test.php. If this works, fill the codeforks with your real config statements.

提交回复
热议问题