[Techtalk] Mod Rewrite rules

Michelle Murrain michelle at murrain.net
Thu Sep 24 17:18:50 UTC 2009

On Sep 21, 2009, at 6:26 AM, Chris Wilson wrote:

> Hi all,
> On Mon, 21 Sep 2009, Wim De Smet wrote:
>> On Sun, Sep 13, 2009 at 8:33 AM, Michelle Murrain <michelle at murrain.net 
>> > wrote:
>>> One thing remains. The main page of the blog is at domain1.com/ 
>>> blog. I
>>> would like to redirect "domain2.com/" (and only that - no other  
>>> pages
>>> below it) to point to /blog
>>> This is what I've got so far in my .htaccess file:
>>>   RewriteCond %{HTTP_HOST} ^domain2.com$
>>>   RewriteCond %{REQUEST_URI} =/
>>>   RewriteRule ^/$ /blog/
>>> Alas, this doesn't work.
>> Did you ever get this to work? It just occurred to me that you might
>> want to rewrite /index.html? as well. Seeing as the browser might
>> default to those (though I'm not entirely sure which he triest  
>> first, I
>> think he only tries them if he gets a 404 on /).
> It doesn't sound like a job for mod_rewrite at all. I'd say this  
> would do
> it much more easily:
> <virtualhost *>
> 	servername domain2.com
> 	redirect / http://domain1.com/blog/
> </virtualhost>

I did actually find a rule that worked. It was, basically, a pretty  
simple thing:

  RewriteCond %{HTTP_HOST} ^blog\.domain2\.com$ [OR]
   RewriteCond %{HTTP_HOST} ^domain2\.com$ [OR]
   RewriteCond %{HTTP_HOST} ^www\.domain2\.com$
   RewriteCond %{REQUEST_URI} =/
   RewriteRule ^$ /blog/ [R,L]

Basically, no "/" between the "^" and "$" of that last line - that's  
pretty much what did it.

Thanks for all the suggestions.

Michelle Murrain
michelle at murrain.net

Blog/Site: http://murrain.net


Let the beauty of what you love be what you do. - Rumi

More information about the Techtalk mailing list