[wp-hackers] OT: htaccess and two domains...

Aaron D. Campbell aaron at xavisys.com
Wed Mar 19 17:21:42 GMT 2008

If you want to redirect them, honestly, this is better done using a 
ServerAlias directive for your VirtualHost in your apache conf (if you can):
<VirtualHost XXX.XXX.XXX.XXX:80>
       ServerName domain.com
       ServerAlias www.domain.com
       ServerAlias domain.net
       ServerAlias www.domain.net

I have a couple posts on some redirects that I've set up ( 
http://xavisys.com/tag/htaccess/ ).   It could be really easy depending 
on your audience, and whether you use SSL or not.  If you use SSL, 
especially if you have mobile users that are using SSL, then read those 
posts.  If you don't, you can redirect like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^preferreddomain.com$ [NC]
RewriteRule ^(.*)$ http://preferreddomain.com/$1 [L,R=301]

That will pass on any url parameters to the preferred domain.

kingler wrote:
> No, I don't think you can. WP does internal redirect based on ONE domain.
> However, you can set up 301 redirects in htaccess so that domain2.net/?p=2
> will automatically redirect to domain1.com/?p=2
> -Liang
> kingler from 72pines
> On Wed, Mar 19, 2008 at 6:39 AM, Mr. Awesome
> <theone.andonly.mr.awesome at gmail.com> wrote:
>> For all you htaccess gurus out there, here's one for you... How can you
>>  get TWO domains, to act as one, depending on the one you land on? Like...
>>  If user Joe comes in on your domain.COM domain, at like. ..
>>  domain.com/?p=2 and then you'd want to have the .NET work and take user
>>  Joe to the same place, just on the .NET, like such: domain.com/?p=2 if
>>  user Joe went there, he'd be getting the same posts, pages, etc etc
>>  without getting 404s and etc. Without mirroring and all that too... When
>>  I had my old host 100megswebhosting.com... they did it for me.
>>  I had TWO domains, taking people to same place... and no matter which
>>  one they landed on, it was at same place, acting like normal blog
>>  without 404s...
>>  domain1.com/?p=2 user got post 2
>>  domain2.net/?p=2 user got post 2 same as they would on domain1.com/?p=2
>>  I hope this isn't confusing... but I got back my original domain:
>>  vindictivebastard.com and instead of having it redirect to the .NET, I'd
>>  like the .NET and .COM acting together as one blog, just two separate
>>  domains.

More information about the wp-hackers mailing list