With add-on domain you probably mean a domain alias, right?
Set your WP_HOME
and WP_SITEURL
to a dynamically value in your wp-config.php
.
This is how it’s done, I use this code all the time it also will define some other constants.
$root="public_html"; //Set this to the DocumentRoot.
define('FTP_USER','<username>'); //Replace <username> with your FTP username.
define('FTP_PASS','<password>'); //Replace <password> the password for that FTP user.
/*## GET CONFIGURATION INFORMATION DYNAMICALLY ##*/
$addr=$_SERVER['SERVER_ADDR'];
$name=$_SERVER['SERVER_NAME'];
$host=$_SERVER['HTTP_HOST'];
$https=$_SERVER['HTTPS'];
$protocol=(!empty($https)&&$https!=='off'||$_SERVER['SERVER_PORT']===443)?'https://':'http://';
$abspath=(strpos(getcwd(),'/wp-admin')!==FALSE)?substr(getcwd(),0,strrpos(getcwd(),'/wp-admin')):getcwd();
$relpath=substr($abspath,strrpos($abspath,$root)+strlen($root));
/*## STORE THE DYNAMIC INFORMATION ##*/
define('WP_HOME',$protocol.$host.$relpath);
define('WP_SITEURL',$protocol.$name.$relpath); ;
define('FTP_BASE',$abspath);
define('FTP_HOST',$addr);
Any feedback on my code is always welcome!