Search code examples
.htaccessmod-headers

backwards or forwards slash in files match .htaccess


I'm unsure whether the following is correct considering I can't find a web example that targets a file inside a directory.

<FilesMatch "/out/index.php$">
Header set X-Robots-Tag "noindex, nofollow"
</FilesMatch>

is it ok that way or:

<FilesMatch "\out\index.php$">
Header set X-Robots-Tag "noindex, nofollow"
</FilesMatch>

Solution

  • First one is the right one as Apache like Unix systems uses forward slash for paths.

    So the right one is:

    <FilesMatch "/out/index\.php$">
        Header set X-Robots-Tag "noindex, nofollow"
    </FilesMatch>