How To Add A Html Header To All Html Pages Of A Folder Automatically With Htaccess?
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:
- How To Include a PHP File Site-wide Using .HTACCESS or other methods and How To Include a PHP File Site-wide Using .HTACCESS or other methods both use PHP to include the files (and just use htaccess to tell PHP where to find the files).
- Apply .htaccess HeaderName to all lower levels? as you discovered, adds the header to the Apache directory listing page only, not to every page on your site.
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?"