.htaccess auto_prepend_file if URL contains

I am trying to automatically include the global.php file using htaccess. Right now i have

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

which works perfect. The problem is that I run this site both on the local development server and on the remote web server for the live site. Thus, it is obvious that the path / local / directory / path will be variable depending on whether I am on mysite.com or mysite.local.

Is there any way to tell if url mysite.local contains this file; otherwise include this file inside htaccess?

+4
source share
2 answers

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 the -D option to the launch command line (-DLOCAL below), and then:

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

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

+2
source

use custodia site settings For lightpd go to php.ini and alocat USD of.user.ini For Apache you need to install AllowOveride All for the YouTube site guide and include the .htaccess file containing "php_value autoprepend_file path" in this directive file

0
source

Source: https://habr.com/ru/post/1482736/


All Articles