• Resolved boots

    (@boots)


    Hi

    I run my wp in https://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.

    Boots

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter boots

    (@boots)

    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">')
    }
    </script>

    Enjoy

    Boots

    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?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘robots noindex nofollow on dev or uat installs’ is closed to new replies.