multiple domains and subdomains to single URL

Using a single web hosting account to host multiple sites

multiple domains and subdomains to single URL

Postby kpmedia » Mon Jun 23, 2008 2:14 am

Two scenarios:

I need to condense 5 domains to http://mydomain.com/
http://mydomain.com
http://www.mydomain.com
http://my-domain.com
http://www.my-domain.com
http://new.mydomain.com

Same for this one, condense all 3 to http://forum.mydomain.com/
http://forum.mydomain.com
http://forum.my-domain.com
http://forum.new.mydomain.com

I've tried a number of rules, but can never seem to get it right.

These are active sites, the domains are set up as domain aliases using the Plesk control panel. Some of the rules I've written would forget the site had more URL after the ".com/" ended.

Hopefully somebody here has the right answer. Thanks.
kpmedia
 
Posts: 2
Joined: Mon Jun 23, 2008 2:09 am

Postby kpmedia » Mon Jun 23, 2008 8:12 am

This is my latest attempt:

Code: Select all
RewriteCond %{HTTP_HOST} ^(www|new)\.(mydomain|my-domain)\.com$ [NC]
RewriteRule ^(.*) http://mydomain.com/$1 [R=301,L]
kpmedia
 
Posts: 2
Joined: Mon Jun 23, 2008 2:09 am

Postby richardk » Tue Jun 24, 2008 2:01 pm

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^forum\.((new\.)?my-example\.com|example\.com)$ [NC]
RewriteRule ^(.*)$ http://forum\.example\.com/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^((www|new)\.)?my-example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 20 guests

cron