I just added a domain addon to my hosting, then I installed WordPress multisite on that addon domain, and the addon domain created an automatic subdomain on my main domain
In cPanel, don’t use the ADDON DOMAIN feature. Use the PARKED DOMAIN feature, parking it on to the primary domain. No sub-domain should be created at all.
Before adding the secondary domain in WordPress, opening it in the browser should take you to the primary domain. Then WordPress can take care of the rest.
don’t use the ADDON DOMAIN feature. Use the PARKED DOMAIN feature
Hi @gappiah
My both domains have different sites, aren’t parked domains only used if you want 2 domain but the content and appearance of the site are the same?
Thank you
My both domains have different sites, aren’t parked domains only used if you want 2 domain but the content and appearance of the site are the same?
What you’re saying is true if you have separate (WordPress) sites, and this is handled by the webserver.
But with Multisite, all the domains (and even subdomains) must point to the same primary domain. Then WordPress Multisite will take care of the redirection to the appropriate sub-site to serve the different WordPress sites. And in cPanel, PARKING is the easiest way to do this, as you don’t have to worry about any redirections or subdomains and subdirectories being created automatically by cPanel.
Actually, you can use add-on domain, as long as you take care to ensure that the addon domain’s site folder is pointed to public_html (if that’s where the primary domain is… and this makes it essentially the same as a PARKED DOMAIN).
And you can even do this without setting up the domain on the server at all: You can simply point the secondary domain(s) to the primary domain directly from your domain registrar (using eg CNAME record, ANAME record, A-record, redirect, etc).
All that matters (from WordPress Multisite’s perspective) is that visiting the secondary domain(s) should lead you to the primary domain… which is generally called “parking”. Then when you add the secondary domain to any sub-site, WordPress multisite can forward the request to the appropriate sub-site.
Sorry @gappiah, your explanation is so long
The question is, how do I redirect users from subdomains to main domains?
Thank you
Sorry, @mushlih: I don’t have a “short” answer.
All I can say is, when you don’t follow best practices, you’re bound to have the sort of problem you’re having. And I don’t have a quick fix for that.
Good luck!