multiple sub.domain.com ==> www.domain.com plus URL rewri

Using a single web hosting account to host multiple sites

multiple sub.domain.com ==> www.domain.com plus URL rewri

Postby hotwheel » Fri Mar 02, 2007 5:42 pm

Moving from WordPress MU back to WordPress 2.1.2

Have multiple sub-domains we want merge into the main domain, but maintain url structure (just chop off the subdomain and deliver a 301):

subA.domain.com/post-titleA/ TO www.domain.com/post-titleA/
subB.domain.com/post-titleB/ TO www.domain.com/post-titleB/

We also want to be adding WWW to the url if absent:

domain.com TO www.domain.com

We also need to maintain the Wordpress rewrite rules currently in place

.htaccess file is currently:

Code: Select all
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress


I have seen the following code accomplish the sub.domain.com TO www.domain.com 301 redirect but need to two to work together:

Code: Select all
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)$ http://www.getelastic.com/$1 [R=301,L]


Any help making this hum would be appreciated.
hotwheel
 
Posts: 2
Joined: Fri Mar 02, 2007 5:27 pm

Postby richardk » Sat Mar 03, 2007 10:22 am

This should work
Code: Select all
Options +FollowSymLinks

<IfModule mod_rewrite.c>
  RewriteEngine On

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

  RewriteCond %{SCRIPT_FILENAME} !-f
  RewriteCond %{SCRIPT_FILENAME} !-d
  RewriteRule . /index.php [L]
</IfModule>
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby hotwheel » Sat Mar 03, 2007 11:54 am

I knew I was close (marketing guys should not have to do this sort of thing).

THANKS a ton for the quick reply and perfect code.
hotwheel
 
Posts: 2
Joined: Fri Mar 02, 2007 5:27 pm


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 34 guests

cron