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
  • veo3 prompt generator
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
    • PC Troubleshooting
    • Gaming Errors & Solutions
    • Computer Hardware
  • Coupons & Deals
  • veo3 prompt generator
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

Cannot Fetch Sitemap in Google Search Console

Discovered – Currently Not Indexed in Google Search Console: What It Means & How to Fix It

Why 2 Backlinks per Article Might Be Killing Your SEO

What is Obsidian? Why Developers Love This Note-Taking App

Want Faster Load Times? Optimize WordPress This Way

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

Share a countdown button to display a password in WordPress
Solutions & Troubleshooting

Share a countdown button to display a password in WordPress

September 11, 2024
admin wordpress dashboard
Themes & Plugins

Introduction to the WordPress Dashboard: Features, Tools, and Navigation

April 25, 2025
My Google Discover traffic skyrocketed after I did these 10 things
Solutions & Troubleshooting

My Google Discover traffic skyrocketed after I did these 10 things

May 14, 2025
Battlefield 1 fix error First time launching 2
Gaming Errors & Solutions

Battlefield 1 fix error First time launching and can’t click “OK” on initial splash screen

September 23, 2024
How to Quickly Delete Spam Comments Using WP CLI with Terminal in WordPress
Solutions & Troubleshooting

Delete Thousands of Spam Comments in 1 Second with WP CLI

September 12, 2024
What is an SSD
Computer Hardware

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

August 4, 2020
Previous Next

You Might Also Like

How to Add a Read More to Product Descriptions in WooCommerce
Solutions & Troubleshooting

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

May 5, 2025
WordPress Covers Every Website Type
Solutions & Troubleshooting

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

April 29, 2025
Optimized Pagination thumbnail
Solutions & Troubleshooting

How I Optimized Pagination and Skyrocketed Traffic

April 28, 2025
How to Pick the Ideal Blogging Platform for Your Needs
Solutions & Troubleshooting

How to Pick the Ideal Blogging Platform for Your Needs

April 1, 2025
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?