.htaccesshttp-headersnofollownoindexx-robots-tag

X-Robots noindex specific page in .htaccess


Can I 'noindex, follow' a specific page using x robots in .htaccess?

I've found some instructions for noindexing types of files, but I can't find instruction to noindex a single page, and what I have tried so far hasn't worked.

This is the page I'm looking to noindex:

http://www.examplesite.com.au/index.php?route=news/headlines

This is what I have tried so far:

<FilesMatch "/index.php?route=news/headlines$">
 Header set X-Robots-Tag "noindex, follow"
</FilesMatch>

Thanks for your time.


Solution

  • It seems to be impossible to match the request parameters from within a .htaccess file. Here is a list of what you can match against: http://httpd.apache.org/docs/2.2/sections.html

    It will be much easier to do it in your script. If you are running on PHP try:

    header('X-Robots-Tag: noindex, follow');
    

    You can easily build conditions on $_GET, REQUEST_URI and so on.