RewriteEngine on RewriteBase / #set env variable if url matches RewriteCond %{QUERY_STRING} ^route=news/headlines$ RewriteRule ^index\.php$ - [env=NOINDEXFOLLOW:true] #only sent header if env variable set Header set X-Robots-Tag "noindex, follow" env=NOINDEXFOLLOW
FilesMatch works with (local) files, not URLs. Therefore, it will try to match only a portion of the /index.php URL. <location> would be more appropriate, but as far as I can read from the documentation, repetitions are not allowed here. So, I ended up with the above solution (I really liked this call). Although php would be a more obvious place for this, it is up to you.
The solution requires mod_rewrite and mod_headers, of course.
source share