Domain Masking with WordPress
Table of Contents
Domain masking allows you to display content from one domain while keeping another domain in the browser’s address bar. While we often suggest parking the domain name, with WordPress, this usually results in redirects. This is because the WordPress database specifies which domain to use in the wp_options table, particularly in the site_url and home_url fields.
How to Implement Domain Masking
Step 1: Locate and edit the wp-config.php File
Open your Site Tools and go to Site -> File Manager. Navigate to the public_html folder of your website, select the wp-config.php file and click the Edit button.
Step 2: Add the Following Lines
Add the following lines before the line that reads /* That’s all, stop editing! Happy publishing. */:
define('WP_SITEURL', 'https://'.$_SERVER['HTTP_HOST']);
define('WP_HOME', 'https://'.$_SERVER['HTTP_HOST']);
The provided code dynamically sets the site_url and home_url based on the domain from which the request is made. This ensures that the site_url and home_url always match the accessed domain.
Step 3: Save Changes
Save the changes to your wp-config.php file to apply them and then verify the functionality of your website by accessing it with both domain names.