Skip to content Skip to sidebar Skip to footer

How To Add A Html Header To All Html Pages Of A Folder Automatically With Htaccess?

I tried this Options +Indexes IndexOptions FancyIndexing VersionSort NameWidth=* HTMLTable Charset=UTF-8 HeaderName /header.html ReadmeName /footer.html IndexIgnore header.html foo

Solution 1:

I think you're confusing HTTP Headers with a HTML "Header" (meaning the top of the page)

A HTTP header is used to define things like the encoding, content type (eg JSON/XML), not to add HTML to the top of another HTML page.

If you want to add HTML to the top of each page, .htaccess isn't the place to do this - you need to use some kind of scripting/programming language (eg ASP/PHP) to include the files.

Note that none of the three SO questions you link do what you want either:


Solution 2:

If someone has the same problem, when you write the full path, /www/pages/header.html is not enough, you must write /home/User/www/pages/header.html (if you're on linux or C://etc... on windows)

Why? because it is shown on several folders (recursively), so the path changes depending on the directory you're in


Post a Comment for "How To Add A Html Header To All Html Pages Of A Folder Automatically With Htaccess?"