Friday , December 20 2024

If the link contains another domain/subdomain

The task is relevant if hosting subdomains refer to the root of the main site, or if several domains are registered as aliases to each other.

If you need to write noindex/nofollow etc., you can simply write a condition in index/header section:

<?php
$host = $_SERVER['HTTP_HOST']; 
 if($host == "old.domain.com" or $host == "www.old.domain.com") {
     echo 'meta name="robots" content="noindex, nofollow"';
 }
?>

Instead of old.domain.com and meta name=”robots” content=”noindex, nofollow” use your actual values.

About admin

Hi there! My name is Iryna, I am a web developer from Ukraine. While working on freelance projects I often face different technical issues and in this blog I publish articles on how to solve them. I am also interested in digital drawing and in this blog you will find brief tutorials that helped me and hopefully can help you as well.

Check Also

How to add 301 redirect to https for Yii2 without .htaccess

I’ve tested different redirect options for .htaccess, but sites keep giving “redirected you too many …

Leave a Reply

Your email address will not be published. Required fields are marked *