[resolved] robots noindex nofollow on dev or uat installs (3 posts)

  1. boots
    Posted 7 years ago #


    I run my wp in http://www.example.com, uat.example.com, and dev.example.com installs for production, user acceptable testing, and development.

    I'd like to create a conditional statement in header.php if I'm running the code on the uat or dev environments that outputs `echo '<meta name="robots" content="noindex,nofollow"> '

    I don't want my uat and dev environment indexed and I don't want to have individual robots.txt files.

    How can I test for subdomains or not main domain?

    Thanks in advance.


  2. boots
    Posted 7 years ago #

    I dug around a bit and got this to work by trial and error. I'm not the sharpest pencil in the pack. This a great feature for proper change management.

    The javascript tests if the hostname is not my production site, and if not it adds noindex, nofollow.

    Of course this goes in the <head> section where other meta calls are made.

    <script language="JavaScript">
    if (!(location.hostname == "www.example.com")) {
      document.write ('<meta name="robots" content="noindex,nofollow">')



  3. waterhasnoenemy
    Posted 7 years ago #

    Hey, you guys sound techie enough to ask about this noindex thing. Please, what and what should get the noindex box checked? Category, archive, tag or all of them. If so how will the search engines index my posts since I in categories?

Topic Closed

This topic has been closed to new replies.

About this Topic