Posts tagged with .htaccess

htaccess Subdomain Redirection

August 8th, 2008

My blog is set up as a subdomain to my main site so http://bobpeers.com/blog/ should really serve the content from http://blog.bobpeers.com.

Just recently I noticed that link pointing to my blog directories but accessed through the main site were not returning 404 pages for missing pages. For example a link pointing to http://bobpeers.com/blog/page-not-here would just serve the content from http://bobpeers.com. To force requests to the blog to be server by the subdomain i just added this line to my .htaccess file.

Redirect permanent /blog http://blog.bobpeers.com

Now any request for a page under the blog subdirectory will be permanently (http code 301) redirected to http://blob.bobpeers.com, so for example:

request http://bobpeers.com/blog/2008/08/page
serves http://blog.bobpeers.com/2008/08/page

Useful guide to using htaccess files

January 24th, 2008

Here’s a really helpfull guide to using .htaccess files with Apache, great for cut and paste examples for when mod_rewrite is giving you a headache.

http://www.askapache.com/htaccess/apache-htaccess.html