ariamckinley
ariamckinley

Reputation: 1132

.htaccess auto_prepend_file if url contains

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?

Upvotes: 4

Views: 1291

Answers (2)

bortunac
bortunac

Reputation: 4828

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"

Upvotes: 0

julp
julp

Reputation: 4010

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)

Upvotes: 2

Related Questions