OhhMuaOhhMua
  • Home
  • Hosting
    • Best Web Hosting
    • Free Web Hosting
    • VPS Hosting
  • WordPress
    • Solutions & Troubleshooting
    • Installation & Setup
    • Themes & Plugins
    • Security
  • Computer Tips
    • Gaming Errors & Solutions
    • PC Troubleshooting
    • Computer Hardware
  • Coupons & Deals
  • Contact Us
Reading: Guide to Using Multiple Domains for One WordPress Website
Share
Notification Show More
Font ResizerAa
OhhMuaOhhMua
Font ResizerAa
  • Computer Tips
  • Hosting
  • WordPress
Search
  • Home
  • WordPress
    • Installation & Setup
    • Security
    • Solutions & Troubleshooting
    • Themes & Plugins
    • Troubleshooting
  • Hosting
    • Free Web Hosting
    • VPS Hosting
    • Best Web Hosting
  • Computer Tips
    • Computer Hardware
  • Coupons & Deals
Have an existing account? Sign In
Follow US
Copyright © 2024 ohhmua. All rights reserved.
OhhMua > Blog > WordPress > Solutions & Troubleshooting > Guide to Using Multiple Domains for One WordPress Website
Solutions & Troubleshooting

Guide to Using Multiple Domains for One WordPress Website

ohhmua
Last updated: September 16, 2024 4:28 pm
ohhmua
Share
4 Min Read
Guide to Using Multiple Domains for One WordPress Website
Guide to Using Multiple Domains for One WordPress Website
SHARE
Contents
Redirect WP_SITEURL and WP_HOMESEO Setup to Avoid Ranking Loss on GoogleFix Font Errors When Running with Additional Domains

The issue is that you have a website with the domain name your-domain.com. However, due to certain requirements, you need to point multiple different domains to this one website, such as your-domain.com.au, your-domain.com.uk, etc. So, how do we point multiple domains to one website running on WordPress?

Guide to Using Multiple Domains for One WordPress Website
Guide to Using Multiple Domains for One WordPress Website

We need to address three issues:

  1. Parked domain (Aliases) on the hosting where the main site is running, ensuring they point to the correct directory of the main site (typically /public_html).
  2. Redirect WP_SITEURL and WP_HOME to the domain that the user is accessing.
  3. Set up SEO to avoid Google flagging multiple sites with duplicate content.

Redirect WP_SITEURL and WP_HOME

For example, when you add the parked domain (Aliases) your-domain.com.au to your-domain.com, by default, when accessing your-domain.com.au, the browser will automatically redirect to the main domain your-domain.com. Therefore, we need to add the following code to the wp-config.php file so that when users access any of the domains, it will stay on that domain, and the links to posts and pages will remain on the domain the user accessed.

Add the following code to the wp-config.php file:

// Multi Domain for a site
define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST']);
define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST']);

Once you add this code, most of the work is done. You will now be able to access the parked domains (Aliases) without any issues.

However, there’s still one problem: when multiple domains point to the same website, it can negatively affect your SEO. Google may identify this as duplicate content, and you could lose your rankings in search results. Don’t worry, though; I have a solution for you.

SEO Setup to Avoid Ranking Loss on Google

If you are using the Yoast SEO plugin, add the following code to the functions.php file in your theme. This will redirect all canonical traffic to the main site and prevent Google from flagging duplicate content when using multiple parked domains (Aliases).

Add this code to the functions.php file:

// canonical - old domain to new domain
add_filter('wpseo_canonical', 'swpseo_canonical_domain_replace');
function swpseo_canonical_domain_replace($url){
    $domain = 'your-domain.com'; // Change this to your main site, for example, your-domain.com
    $parsed = parse_url(home_url());
    $current_site_domain = $parsed['host'];
    return str_replace($current_site_domain, $domain, $url);
}

If you are using the All in One SEO plugin, add the following code to functions.php:

// canonical - old domain to new domain
add_filter('aioseo_canonical_url', 'aioseo_canonical_domain_replace');
function aioseo_canonical_domain_replace($url){
    $domain = 'your-domain.com'; // Change this to your main site, for example, your-domain.com
    $parsed = parse_url(home_url());
    $current_site_domain = $parsed['host'];
    return str_replace($current_site_domain, $domain, $url);
}

Fix Font Errors When Running with Additional Domains

Once you’ve set up multiple domains to run on a single WordPress source, you might encounter issues with fonts not loading, such as icon fonts not displaying, as shown below:

Error:

“Access to Font at … from origin … has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin … is therefore not allowed access.”

Fix Font Errors When Running with Additional Domains
Fix Font Errors When Running with Additional Domains

To fix this issue, copy the following code into the .htaccess file:

<IfModule mod_headers.c>
    <FilesMatch "\.(ttf|ttc|otf|eot|woff|woff2|font.css|css|js)$">
    Header set Access-Control-Allow-Origin "*"
    </FilesMatch>
</IfModule>

You Might Also Like

My Google Discover traffic skyrocketed after I did these 10 things

How to Add a “Read More” and “Show Less” Button to Product Descriptions in WooCommerce

Blog, E-Commerce, or Forum? WordPress Covers Every Website Type!

How I Optimized Pagination and Skyrocketed Traffic

How to Pick the Ideal Blogging Platform for Your Needs

TAGGED:Multiple Domains
Share This Article
Facebook Twitter Email Print
Leave a comment Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Trending Stories

Top Free WordPress Plugins for Bloggers in 2025
Themes & Plugins

Top Free WordPress Plugins for Bloggers in 2025

May 3, 2025
wordpress.com vs wordpress.org
Themes & Plugins

WordPress.com vs WordPress.org: A Beginner’s Guide to Choosing the Right Platform

April 26, 2025
What is an SSD
Computer Hardware

[The Truth] What is an SSD? Does an SSD Help You Game Faster?

August 4, 2020
GTA 6 50 Fan Discoveries You
Gaming Errors & Solutions

GTA 6: 50 Fan Discoveries You Should Know – Full Breakdown

May 9, 2025
GPU Fan Not Spinning
Computer Hardware

GPU Fan Not Spinning: Causes and Solutions

July 22, 2023
How to Install and Use Google Analytics 4
Installation & Setup

How to Install and Use Google Analytics 4 (GA4) in 2025: A Step-by-Step Guide

April 21, 2025

You Might Also Like

Protecting Your WordPress Site from File Upload Vulnerabilities
Solutions & Troubleshooting

Protecting Your WordPress Site from File Upload Vulnerabilities

September 26, 2024
Title and Meta Description Mismatch on Google
Solutions & Troubleshooting

Title and Meta Description Mismatch on Google[How to fix]

September 25, 2024
Contact button
Solutions & Troubleshooting

Contact button in the footer with added call button shake effect

September 21, 2024
Guide to Creating a Beautiful Promotion Notification Box for Your Website
Solutions & Troubleshooting

How to Create a Stunning Notification Box for Your Website

September 20, 2024
Previous Next
newsletter featured

Always Stay Up to Date

Subscribe to our newsletter to get our newest articles instantly!

Follow US on Social Media

Facebook Youtube Steam Twitch Unity

Copyright © 2024 ohhmua. All rights reserved.

OhhMua

Information

  • About
  • Terms & Conditions
  • Privacy Policy
Welcome Back!

Sign in to your account

Lost your password?