Page 1 of 1
add header to all pages with htaccess?
Posted: Sun Jan 15, 2006 5:23 am
by hanzo
Is it possible to add a header to all pages with the use of a htaccess script?
Thanks
Hans
Posted: Sun Jan 15, 2006 11:42 am
by Chris Corbyn
Posted: Sun Jan 15, 2006 1:28 pm
by hanzo
thanks but can you give me an example how to add by example header.html to every page because I don't understand alot of it
Thanks
Posted: Mon Jan 16, 2006 6:22 am
by foobar
hanzo wrote:thanks but can you give me an example how to add by example header.html to every page because I don't understand alot of it
Thanks
You should have been more specific about what you want. When you use the word "header", most people will associate this with "HTPP Header".
What you want, is a piece of HTML code that is prepended to your page.
In your .htaccess file, include this:
Code: Select all
php_value auto_prepend_file /full/path/to/file.html
Note: This will only work if PHP is run as an Apache Module.
Posted: Mon Jan 16, 2006 7:05 am
by raghavan20
Note: This will only work if PHP is run as an Apache Module.
I am just now learning apache so I do not really understand the difference between running PHP and running it as a PHP module. Do you mind explaining the same?
Posted: Mon Jan 16, 2006 7:20 am
by foobar
raghavan20 wrote:I am just now learning apache so I do not really understand the difference between running PHP and running it as a PHP module. Do you mind explaining the same?
To put it simply:
- If you run PHP as a CGI binary, Apache basically redirects all requests of PHP files to an executable which then processes the request.
There are several
security considerations associated with this.
- If you run PHP as an Apache module, then the PHP interpreter runs as a "sub-program" of Apache.
It consequently inherits Apache's permissions and settings. This means that the PHP interpreter can cooperate with Apache on a certain level (hence the .htaccess command mentioned earlier). However, there are also some
exploits possible when PHP is run as a module.
Posted: Mon Jan 16, 2006 12:14 pm
by timvw
An article with a couple of interesting links (explaing difference between running php as module and cgi)
http://www.sitepoint.com/blogs/2006/01/ ... n-why-php/
Posted: Tue Jan 17, 2006 10:35 am
by hanzo
Thanks for all replies.
foobar, is there a way to make the header add to all files in all directories?
When I access a file, by example website.com/map/file.htm it doesn't get the header only files in the main directory get it.
Thanks
Posted: Tue Jan 17, 2006 11:01 am
by Chris Corbyn
put the .htaccess file in each directory OR add the confiuration directly to httpd.conf if you have access to it.