How to Redirect a Subdomain to a Root Domain (e.g. to

I had a Google Search Console issue today where it was seeing a bunch of staging urls that no longer exist. I don’t know how they got there, but here we are. 🙂 To resolve this issue, I had to:

  1. Add the staging url to the server as an addon domain.
  2. Add the following to .htaccess:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^$ [NC]
RewriteRule ^(.*)$$1 [R=301,L]
  1. Update the dns “A” record for “staging” so it points to my root domain server.

That’s it!

Posted in

Toby Cryns

Toby Cryns is a freelance CTO, expert WordPress consultant, and teacher.

He offers free advice to improve your freelance biz.

He also publishes small droppings every now and then to and

Follow Toby's contributions on Github and