Reputation: 43
I'm running a minor WordPress (multisite/network) site, on a server using cPanel. The site used to have a lot of subdomains like:
shop.example.com
cars.example.com
music.example.com
The problem:
Most of the subdomains are no longer available (neither in the DNS nor anywhere else) - so when you try to reach shop.example.com it just hits a 404.
So my question is:
How do I get all subdomains to redirect to example.com
?
What have i done/tried already:
*.example.com
record pointing to the correct IP*.example.com
record pointing to example.com
shop.example.com
*.example.com
), and a couple of other different thingsSo what am I doing wrong? I'm pretty sure I need to do a combination of setting up a wildcard DNS record, and doing something in CPanel :P - but I just can't figure out exactly what.
Upvotes: 1
Views: 850
Reputation: 2693
From your post
Doing this forced it onto the server, so its no longer just a 404, but the server doesn't recognize
shop.example.com
You then need to do a 301 Redirect from shop.example.com
to wherever you want to go, you can do this is in the CPanel. You will have to do this for each subdomain that that once existed therefore handling any requests that might come.
Unfortunately, there isn't a way to use the wildcard like you can for the IP. Each subdomain is a separate website as far as the webserver software, such as Apache, is concerned. So when you do a redirect you are answering the webserver software question, "OK, I got a HTTP GET request for shop.example.com
, what files do I serve up? "
See this section in the CPanel docs for more information on redirecting.
Upvotes: 1