Using mod_rewrite to add 'www' to urls

Here's a working version I have on my laptop:

RewriteCond %{HTTP_HOST} ^localhost$ [NC] RewriteRule ^(.*)$ http://www.localhost/$1 [L,R=301]

Yeah, you have to use those rules first or some other rules might fire first instead.

Does this help?

RewriteLogLevel 9 RewriteLog logs/rewrite.log

Greg Donald wrote: > Does this help? > > RewriteLogLevel 9 > RewriteLog logs/rewrite.log

Nay. I assume it would create the logs directory if it didn't already exist? It doesn't.

I always have to make an explicit entry to get rewrite logs.

By the way, I dig your site. :slight_smile:

Thanks. It's just a little something I threw together one afternoon. :slight_smile:

Out of curiosity, why would you want to make the canonical URI have www appended to it? For me, it seems so antiquated like ooooh double u double u double u dot … That’s just me though. I’m legitimately curious about any benefits [perceived or actual] for the extra www.

RSL