dsxay48646
2013-05-25 16:18 阅读 57
已采纳

.htaccess auto_prepend_file如果url包含

I'm trying to auto include a global.php file using htaccess. Right now I have

php_value auto_prepend_file "/local/directory/global.php"

which works perfect. The problem is, I run this site both on a local server for development, and a remote web server for the live site. So obviously the /local/directory/ path is going to be variable based on whether I'm on mysite.com or mysite.local.

Is there a way to say if url contains mysite.local, include this file; otherwise include this file, inside the htaccess?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • 已采纳
    doufuxing8562 doufuxing8562 2013-05-25 17:47

    You need Apache >= 2.4 to make this really conditional.

    <If "%{HTTP_HOST} == 'mysite.local'">
        # ...
    </If>
    <Else>
        # ...
    </Else>
    

    For earlier versions, this is only possible by adding a -D option to the startup command line (-DLOCAL below), then:

    <IfDefine LOCAL>
        # ...
    </IfDefine>
    <IfDefine !LOCAL>
        # ...
    </IfDefine>
    

    (for Apache >= 2.4, see also the Define directive - same effect as adding a -D argument)

    点赞 评论 复制链接分享
  • dongshuanggu4333 我在西湖1 2013-08-01 14:27

    use site custodia settings For lightpd go in php.ini and alocat the USD of .user.ini For Apache must set the allowOveride All for YouTube site directori and plase in that directori a .htaccess file containing " php_value autoprepend_file path"

    点赞 评论 复制链接分享

相关推荐