add header to all pages with htaccess?

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
hanzo
Forum Newbie
Posts: 16
Joined: Thu Nov 17, 2005 10:14 am

add header to all pages with htaccess?

Post by hanzo »

Is it possible to add a header to all pages with the use of a htaccess script?

Thanks
Hans
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

hanzo
Forum Newbie
Posts: 16
Joined: Thu Nov 17, 2005 10:14 am

Post 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
foobar
Forum Regular
Posts: 613
Joined: Wed Sep 28, 2005 10:08 am

Post 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.
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post 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?
foobar
Forum Regular
Posts: 613
Joined: Wed Sep 28, 2005 10:08 am

Post 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.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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/
hanzo
Forum Newbie
Posts: 16
Joined: Thu Nov 17, 2005 10:14 am

Post 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
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

put the .htaccess file in each directory OR add the confiuration directly to httpd.conf if you have access to it.
Post Reply