Forum Moderators: phranque

Message Too Old, No Replies

Conditional Files directive

         

moroandrea

7:40 pm on Jun 20, 2011 (gmt 0)

10+ Year Member



Hi All,

I'm in a situation with a static web site with a discrete number of files and folders ramification.

I was interested adding a rel canonical tag via HTTP Header. However, I've read so far that the file name need to be declared in the files "directive", or eventually can be generalized with something like

<Files ~ "\.html$">
Header append Link "<http://www.example.com/white-paper.html>; rel=\"canonical\" \"noarchive\""
</Files>

(I'm not sure the above syntax proposed is correct as I never tested it.)

As the canonical tag does require a URL, I was wondering if I can use the () operator to grab the file name currently processed and use in the following line ... something like

<Files ~ "(.*?)">
Header append Link "<http://www.example.com/"$1>; rel=\"canonical\" \"noarchive\""
</Files>

(Again, the above syntax has not been tested, and I strongly doubt it works).

I have to remit to your knowledge, as I don't know really how to further proceed.

Many thanks for any help.
Andrea