[Scottish] mod_rewrite help

Mike Quin mike at elite.uk.com
Sun Jan 14 10:10:14 GMT 2007

On Sun, Jan 14, 2007 at 01:43:18AM +0000, Kyle Gordon wrote:

> I have my website at http://lodge.glasgownet.com/ which has a blog at
> http://lodge.glasgownet.com/blog/. I'd like to transparently redirect
> all requests to / to /blog/, but keep other subdirectories in the root
> useable.
> At the moment I use RewriteRule ^$ http://lodge.glasgownet.com/blog/
> [R=302,L] which redirects the browser but fails to make it transparent.

The trick here is to use a RewriteRule to catch the index rather than
the directory - this will catch visitors to / but leave your
subdirectories alone.

RewriteRule ^/index.html$ /blog/index.html 

> I'd also like subdirs of /blog/ to be mapped back to / as well, like
> making http://lodge.glasgownet.com/blog/2007/01/09/electricity-meter/
> available from http://lodge.glasgownet.com/2007/01/09/electricity-meter/

Assuming that format is going to be reasonably consistant:

RewriteRule ^/([0-9][0-9][0-9][0-9])/(.*) /blog/$1/$2 

Mike Quin <mike at elite.uk.com> :: "It's not MY god damn planet!
                              ::  Understand, monkey boy?"

More information about the Scottish mailing list