Free Game Downloads -- Sodaware.net

Free Game Downloads -- Role Playing Games, Puzzle Games and Action Games.

Changing the header image every month

Find out how to change your blog’s header image every month by using a little bit of server-side trickery.

One of the things I did with the old design of this blog was to change the header image every month, and it’s something I use on my other website (philnewton.net). I could have done this by uploading a new image every month, but being a programmer I decided to do it a different way.

Using mod_rewrite to change the image

If you’re using an Apache server, you can use something called mod_rewrite to rewrite URLs and do other nifty tricks. I used this to change the image the user saw every month.

I keep all the images in my images folder, and name them according to the month I want them to show. For example, the March image will be called “03-header.jpg”, and the December image “12-header.jpg”. I then use a little mod_rewrite trickery to redirect requests to the correct location. The code looks something like the following:

<ifmodule mod_rewrite.c>
  RewriteEngine on
  RewriteRule ^images/header.jpg$ /images/%{TIME_MON}-header.jpg
</ifmodule>

This code is placed in a “.htaccess” file that resides in the html root folder on the server. This is the folder where all the other folders and files are kept. I put it here instead of in the blog folder because WordPress has its own “.htaccess” file which sometimes changed and removed my tweaks.

Using it in the template

You don’t have to make any changes to your html templates, just make sure you link to the image as “header.jpg” and not something like “12-header.jpg”. The server will take care of all the redirection all on its own, and it won’t disturb anyone’s browsing experience.


These icons link to social bookmarking sites where readers can share and discover new web pages.

Article Info

Date: June 26, 2006

Author: Phil Newton


Categories:

Hot Game Downloads

Fatal Hearts

Fatal Hearts

Solve the mysteries behind your dreams in Fatal Hearts!


Neon Wars Neon Wars
Fill your screen with an explosion of colour!
Steam Brigade Steam Brigade
A beautiful strategy game with a unique twist!

No comments have been posted yet. Why not be the first?


Leave a comment [TrackBack URI]


Tags Allowed: a, abbr, acronym, b, blockquote, code, em, i, strike, strong



Browse By Date

Adventures in Shareware

Welcome to "Adventures in Shareware", the blog of an indie software business known only as "Sodaware". Learn all about indie games, the people that make them and how you can improve your own indie business.

Download Free Computer Games | Site Map | Links | Contact Us

© 2005-2007 Sodaware. All rights reserved. About Us | Privacy Policy