0

I have a website with its main domain name and an add-on domain.

When I access the Wordpress site from the main domain, CSS/JS loads without any issues.

When I access the site through the add-on domain, CSS/JS doesn't load, however the links work!

My .htaccess file looks as follows:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Do I need anything else?

Also, my hotlink protection of my site is disabled.

Any help or pointers will be appreciated!!!

Thanks

0

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!

|improve this answer|||||
  • 1
    this is absolutely brilliant! Many thanks for your help. Actually, I didn't have to define the FTP_User and FTP_PASS variables, as the rest of the code works without any issues! Thanks, again. – user2135025 Feb 6 '15 at 15:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.