简体   繁体   中英

IF in htaccess. Want to use different include_path for different servers

I develop websites on my local webserver, the develop server. Whenever development is finished I transfer the website to it's live server. For the develop and the local server some different .htaccess settings are needed, for instance:

php_value include_path ".:/Localserver/global/stuff_develop/"
php_value include_path ".:/Liveserver/global/stuff_live/"

I would like to have some sort of IF statement in my htaccess that enables it to use the right include_path based on the server it sits on. This makes it possible to transfer the .htaccess file without having to change it to facilitate for the server it is on. Is this possible, and if yes, how would I do this?

I already tried playing around with SetEnvIf which sets a _SERVER variable "local" to value "1" when we're on the local server. Could this be used in htaccess itself for this purpose?

Thanks in advance!

Have you tried solving this in PHP using ini_set('include_path', ...) ?

Eg if a page script resides in "/Localserver/site1/pages" resp. in "/Liveserver/site3/pages" something like

$basepath=dirname(dirname(__FILE__));
switch ($basepath) {
    case ('/Localserver'): ini_set('include_path',...) ; break;
    case ('/Liveserver'): ini_set('include_path',...) ; break;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM