Forum

Thread tagged as: Question, Configuration, Hosting

Perch .htaccess X-robots tag

Hi, I've deployed a site to my staging server for testing / approval and would like to prevent search engines from indexing the staging site. In the past I've used the X-robots tag in my .htaccess file but this doesn't seem to be working on this site.

Full disclosure, I'm a front-end guy so .htaccess is usually a little over my head. But I've previously done this with no problems. I'm using the example Perch .htaccess file code below:

<IfModule mod_rewrite.c>

    RewriteEngine on

    # Prevent search engine indexing for staging site
    Header set X-Robots-Tag "noindex, nofollow"

    # Redirect to PHP if it exists.
    # e.g. example.com/foo will display the contents of example.com/foo.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}.php -f 
    RewriteRule ^(.+)$ $1.php [L,QSA]

    RewriteRule ^blog/([a-zA-Z0-9-/]+)$ /blog/post.php?s=$1 [L]

</IfModule>

Any ideas where I'm going wrong?

Thanks in advance!

Alan Charlesworth

Alan Charlesworth 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

This isn't so much a Perch question, so this forum might not be the best place to get a quick response.