I have this code here:
$config['SUBFOLDER'] = '/';
$config['APP_URL'] = 'http://'.$_SERVER['HTTP_HOST'].$config['SUBFOLDER'];
And APP_URL is used throughout the HTML templates. The problem is – the config needs to be as universal as possible, so there’s less to do when switching environments.
Now, it works like this when I have configured a virtual host for my project, but when it isn’t a virtual host, but sort of a localhost/myproject/ – the $config[‘SUBFOLDER’] has to be set manually to /myproject/
How do I do this programmatically?
You could set a variable in, for example, your htaccess file.
then in your website do a check for this:
With this approach you only need to change one variable in the htaccess file.
If you just want to check if you are running on localhost, doing a check on
$_SERVER['HTTP_HOST']will also work: