Perl programmer for hire: download my resume (PDF).
John Bokma MexIT
freelance Perl programmer

Rewriting URLs for Google

Monday, April 12, 2004 | 0 comments

Using the Google Toolbar I noticed that my site has two different PageRank values. One for the domain name with the www prefix and one for without the www prefix. In a thread on Google PageRank in the Usenet group alt.www.webmaster it was suggested to use a 301 redirect in order to get a combined and probably higher Google PageRank value.

Using mod_rewrite to remove the www subdomain

Alfred Molon gave a link to an article which describes the 301 (permanent redirected) method. And Google's Webmaster info even recommends this redirection technique. Edward Alfert posted an Apache mod_rewrite version he uses. I changed the domain name and also added the $ to the regular expression used by RewriteCond to make the match an exact one.

RewriteEngine On
RewriteCond %{HTTP_HOST} !^castleamber\.com$
RewriteRule (.*) http://castleamber.com/$1 [R=301,L]

This rule redirects to http://castleamber.com/ if the HTTP_HOST value doesn't match castleamber.com. So a visit to http://www.castleamber.com/ is 301 redirected to http://castleamber.com/, a URL rewrite that effectively removes the, what I consider obsolete, www prefix.

So I put those lines into a .htaccess file, which I uploaded to the document root of my Castle Amber website and repeated the process for this site.

Search engine friendly dynamic pages

In a thread on dynamic pages and search engines, Brucie posted in alt.www.webmaster a nice list on making those web pages search engine friendly:

Also today

Please post a comment | read 0 comments | RSS feed