Tutorial - Dynamic Base Url | Vevioz Community

Tutorial Dynamic Base Url

DevOps

Linux Systems Engineer
Joined
Oct 18, 2019
Messages
136
Reaction score
11
Points
18
Location
Indonesia
Website
www.anymusics.com
Offline
Many times the base url in config/config.php must be set it to localhost for development and reset when it goes live. More importantly is when you are dealing with a single application accessible from multiple domains. So this provides the ability to easily set the value dynamically. I am not sure why I have neither come across anyone mentioning issues with it or its requirement considering what can be easily achieved. Never the less it is still very simple although you could add security measures since the input instance is not directly available in the config files since they don't reside in the superclass.

Just overwrite the line in config/config.php with the following:

Code:
$site_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]";
 
Top Bottom