Apache mod_rewrite

Tip No Comments »

I used to have my blog at http://www.rjb.za.net/wordpress/. If anyone visited my site directory to http://www.rjb.za.net/ there was a php script that redirected to /wordpress. This is not very good for spiders to index because I loose points on the redirects. So I decided to move the blog permanently to www.rjb.za.net/. Much moving of files later, this was done.

This worked pefectly except it broke all links in any search engine. This sucked. Big Time. I remembered Grant speaking about mod_rewrite. This is a little module in Apache that allows you to rewrite URLs dynamically. In fact it is used in most Wordpress blogs everyday to use nice clean URL’s for all entries.

The plan I put together was this. Rewrite all URLs for http://www.rjb.za.net/wordpress/$1 to http://www.rjb.za.net/$1 ($1 being variable URLs). As well as this I wanted to tell the browser/spider that the old URL has been permanently moved. This will cause spiders to reindex my page. So I need to include the HTTP code 301 which coincidently is the code for Moved Permanently. So after looking at this great guide on rewriting URLs, this is the code I put in my .htaccess file and causes this wonderful rewrite to happen:
RewriteEngine On
RewriteBase /
RewriteRule ^wordpress/(.+) /$1 [R=301,L]

Sweet and easy, this causes the URLs to be rewritten in the case of looking for the /wordpress directory and tell the browser that it has been moved permanently. Essentially one line of code for this.

Of course all of you already know this and are probably laughing at my solution and saying: “Goddammit, you should have known this already!”. Oh well, learn somtin’ new everyday :)

Tip of the Day

Tip 1 Comment »

Hey All.

I came across this great tip from Jason McC’s blog that makes your fonts in Windows XP look amazing… Its called cleartype. Have a look at the instructions at the end of this post and try it out for yourself.

Clicky

UPDATE

Woops … forgot to include that this is for LCD screens only.