seo – Will this snippet of code hide my subdomain from search results without impacting the root domains visibility?
I’ve been working on a staging site, installed to a subdomain with installatron. It appears that a good portion of this staging site has now been indexed and shows up when you search for our business. I’ve set up a error page with a link back to our public website, but have failed to make a 301 redirect work, with either a plugin or a cpanel redirect.
After more reading it looks like the correct answer is to put this code in the functions.php file of my staging sites child theme – but I would like someone to confirm that this will do what I’m hoping?
add_action('wp_head', 'no_robots_wp_head');
function no_robots_wp_head(){
?>
<meta name="robots" content="noindex, nofollow" />
<?php
}
In theory I want this to get google to de-index all pages of subdomain.website.ca while keeping website.ca indexed as is.
Leave an answer