Dynamically conifugre paths in your WordPress config file.
Open a terminal in the same folder as your wp-config.php
file.
composer require lsvh/dynamic-wp-config
Afterwards you should add the following to the top of your wp-config.php
file.
require_once __DIR__ . '/vendor/autoload.php';
Usually you will do something like...
use \LSVH\WordPress\DynamicConfig\Init as DynamicConfig;
define('WP_HOME', DynamicConfig::url_with_path());
define('WP_SITEURL', DynamicConfig::url_with_path());
url_with_path($install_dir = '')
Returns the full URL to the WordPress site.
- string
$install_dir
: Use this parameter to append the installation directory. Necessary if you installed WordPress in its own directory (Default is''
).
force_protocol($to = 'https')
Redirect the WordPress website to a particular HTTP protocol.
- string
$to
: The protocol to redirect to (Default is'https'
).
force_subdomain($to = 'www.')
Redirect the WordPress website to a particular subdomain.
- string
$to
: The subdomain to redirect to (Default is'www.'
).
avoid_subdomain($from = 'www.')
Redirect the WordPress website to the domain without subdomain to avoid the given subdomain.
- string
$from
: The subdomain to avoid (Default is'www.'
).
force_domain($to)
Redirect the WordPress website to a particular domain.
- string
$to
: The domain to redirect to.
MIT © LSVH