Adding favicon.ico to every web page

Edit May 2nd, 2009: It’s amazing that I still get hits for this web page.  This info was from 2005 and these days it is easy to add a favicon.ico just by putting a copy in your web servers root directory.

Original post below.

– – – – – – – – – – – – – – – – – – – – – – – –

Recently I figured that I would add an icon for the web pages. After some digging I found that in order to do this, all you need to do is put a Windows formated favicon.ico file on your web server and add the following tags

<link rel=”icon” href=”/favicon.ico” type=”image/x-icon”>
<link rel=”shortcut icon” href=”/favicon.ico” type=”image/x-icon”>

within the <HEAD> portion of the web page. The second tag seems to be for Internet Explorer. Pretty easy to do, an when you add that URL to your favorites in Internet Explorer, the icon gets listed in the menu next to the title.

In Firefox it’s even better. The icon next to the URL http://www.dembowski.net/ shows up there too. Very cool. I put the favicon.ico I created on my web root so http://www.dembowski.net/favicon.ico works.

Then I realized that in order to get the icon onto all my pages I would have to insert that HTML tag into every page by hand.

Not so cool. Some of the pages, WordPress blog software for example, were not created by me. I can modify them but that is potentially a lot of pages to mess with.

I run this server on a Linux distribution (Fedora Core 1) and am running this blog on the Apache 2.0 web server software. It’s a good environment and just about every idea has been done already.

Turns out there is an Apache module called mod_layout (http://tangent.org/index.pl?lastnode_id=478&node_id=362) that can dynamically modify web page content based on entries in the config file.

So I downloaded the latest source from the author’s web site (http://download.tangent.org/mod_layout-4.0.2a.tar.gz) uncompressed the software and built.

That’s when the fun began. The documentation I found online is dated and no longer entirely applicable. The mailing list archives were not much help either. I could have sent the author an e-mail (the mailing list archive shows he’s a really good guy) but I A) did not want to bug him for a RTFM question and B) why couldn’t I just figure it out? I have the source code after all.

After looking at the source code and trying unsuccessfully to figure it out, I reasoned that some distribution (not Fedora) bundles mod_layout. I went onto google and found apache2-mod_layout-2.0.48_4.0.1a-2sls.i586.rpm. It’s part part of the OpenSLS distribution which I never even heard off. This rpm contained a well commented config file 15_mod_layout.conf which spelled out what each config option does.

I’ve put a copy of that sample conf file at http://www.dembowski.net/15_mod_layout.conf. OpenSLS apparently became Annvix at http://annvix.org/.

On Fedora Core 1, I needed to install the httpd-devel package (yum install httpd-devel as root). The Makefile needed be changed since Fedora moves the apache source and utilities from the default.

The diff for the Makefile is

$ diff Makefile mod_layout-4.0.2a/Makefile
5,7c5,7
< top_srcdir=/usr/local/apache2
< top_builddir=/usr/local/apache2
< include /usr/local/apache2/build/special.mk

> top_srcdir=/usr/lib/httpd
> top_builddir=/usr/lib/httpd
> include /usr/lib/httpd/build/special.mk

Then as root just

$ cd mod_layout-4.0.2a/
$ make && make install

This will build and copy the binary mod_layout.so to /usr/lib/httpd/modules add to the /etc/httpd/conf/httpd.conf file the line

LoadModule layout_module /usr/lib/httpd/modules/mod_layout.so

Which I copied and deleted. The httpd.conf file is part of the httpd rpm package; I try to not mess with that except when needed. Instead in the /etc/httpd/conf.d directory I created a file called mod_layout.conf. All *.conf files in that directory get read and included, so modifying the the main file is just not needed.

In that file I placed the following lines:

LoadModule layout_module modules/mod_layout.so
AddOutputFilter LAYOUT html

Layout “<HEAD>” “<link rel=”icon” href=”/favicon.ico” type=”image/x-icon”><link rel=”shortcut icon” href=”/favicon.ico” type=”image/x-icon”>” append

LayoutComment On

First line is loads the mod_layout module. Then I have a AddOutputFilter LAYOUT for html. I have to try peppering a plain text file with <HEAD> just to see what happens, but the filter should only be engaged for HTML content.

The Layout command is where the good stuff happens. Whenever the <HEAD> string is seen, it appends right after that the two tags

<link rel=”icon” href=”/favicon.ico” type=”image/x-icon”><link rel=”shortcut icon” href=”/favicon.ico” type=”image/x-icon”>

This way I keep the <HEAD> tag intact and get what I want, a reference for the icon on every web page. I added the LayoutComment On as a sanity check.

Here is the difference it makes. For http://www.dembowski.net/foo/junk.html

<HTML><HEAD><TITLE>mod_layout test</TITLE>
</HEAD>
<BODY BGCOLOR=”#fefefe” TEXT=”#222222″ LINK=”#000000″ VLINK=”#222222″>
TEST OF GAH!
</BODY>
</HTML>

Comes out as

<HTML><HEAD>

<!– Beginning of: Static Content –>

<link rel=”icon” href=”/favicon.ico” type=”image/x-icon”><link rel=”shortcut icon” href=”/favicon.ico” type=”image/x-icon”>

<!– End of: Static Content –>

<TITLE>mod_layout test</TITLE>
</HEAD>
<BODY BGCOLOR=”#fefefe” TEXT=”#222222″ LINK=”#000000″ VLINK=”#222222″>
TEST OF GAH!
</BODY>
</HTML>

Which works exactly as I wanted. It’s all good.

The only minor drawback I see is that the next time I get an update to my httpd package (security, bug fix, developers added something, etc.) I’ll have to rebuild the module.

Okay found one commercial product for posting.

BlogJet logo

Hrm. Here is an interesting program. BlogJet is a windows application that gives a GUI for blog posts. It supports

  • Bullets
  • Spell Checking
  • Insertion of links to images (see above logo)
  • And comes with a 30 day trial

It has all of the usual formating tools one would expect from a word processing like tool.

I’ll kick it around for a while and see if it works for me.

Interesting application this WordPress

After a couple of days I can see that blog’s are an interesting concept, and light weight software on the server and client. Using WordPress I can

  • Write and publish content,
  • I can play with the theme of the blog,
  • Administer the blog,
  • install new themes, plugins, etc.

All done with very little effort; this software is very easy to use. WordPress was disturbingly quick to install and very little Geek Points needed to set this up. Total time spent setting this up was all of 45 minutes, and mostly because I did not read the easy to read and search online help. But I also see that there are some (minor) drawbacks.

I have not yet seen (okay in a few days) a good interface for formating and dropping in graphics. The default tool is very good and easy to use but requires the author to insert HTML codes. What I’d like to see is some sort of editing tools along the lines of gmail’s interface. Gmail’s compose mail tool let’s you format the text, insert bullets, change font and size, etc. I’m very happy with WordPress and will keep looking for someway to do this. GMail might actually work; I can setup a mail account and post via that e-mail. I’ll set that up and see if it preserves the html formatting.

F.E.A.R. Game

Two weeks ago I purchased a really cool game called F.E.A.R.

This is a scary well written horror/action flick. It’s meant to be played in the dark with the volume turned up. And the kids asleep, the game is very graphic.

The game is so good, I upgraded my 128MB Geforce 5700 to a BFG 6800GT OC 256MB DDR card. It was well worth it, even if I still cannot run the game at the maximum settings.

Welcome to my server.

Paraphrasing from the original web page:

Welcome to the Dembowski.net Consulting home Page.

The majority of our work has been related to firewalls, IP routing w/UNIX based servers, and mail systems of different types (SMTP connectivity).

Around 1994 the forces of the universe conspired to change my method of employment from a regular salaried employee to a paid by the hour consultant. This has various pros and cons.

My main interest for a long time has been IP networking. This naturally led to my getting very involved firewalls such as the TIS Firewall Tool kit, Checkpoint Firewall-1, and Gauntlet.

It also meant that I got involved in UNIX and variant operating systems such as Linux. When I got involved in Intel based UNIX all that was available at that time was SCO. That system had a Digiboard and 15 WYSE-50 terminals. The support from SCO was “we don’t support that hardware. Buy a real computer and than call us back.” So when my brother Ed introduced me to Slackware Linux I was dubious. The operating system at that time was 0.99pl11! But it worked with our hardware and was more UNIX than SCO (IMHO).

I’ve been using Linux for several years now. I’ve moved from Slackware to RedHat because the package management was superior, now I just stay because I’ve gotten used to the setup. From Redhat to Fedora.

This box is running Fedora Core 1 and handles our e-mail and web page. It’s running on a dual processor P3 933MHz with 256MB of RAM.

The text never really got updated and is well silly. I think all home/hobbyist web sites really want a running log.

1997. I think.

The original web page for www.dembowski.net has not changed since 1997. At the time the tools that existed on the Internet were Netscape and some not very good Microsoft Office tools. On the server side the pages were static.

Now in 2005 there are tons of tools. This blog is currently using WordPress 1.5.2. I selected WordPress because it is free, works with a MySQL database, and PHP.

My server has those tools so here we are.