homepage Welcome to WebmasterWorld Guest from 54.167.185.110
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Redirecting subdomains to main domain
All with different IPs
Eugenios




msg:1509376
 12:50 pm on May 6, 2005 (gmt 0)

Hello,

I have these domains:

blue.widgets.com
nice.widgets.com
www.widgets.com

All with different ips and in the same server. But the first two point (they POINT TO, they are not 301 redirected) to the main site (that is, to the same directory in the server). Like this:

blue.widgets.com ---> serverroot/widgets/
nice.widgets.com ---> serverroot/widgets/
www.widgets.com ---> serverroot/widgets/

Since this situation was poorly managed, I ended up with duplicated sites.

I would like to point each of the first two sites to different directories, and place an htaccess in each directory to 301 REDIRECT each site to the main site. Like this:

blue.widgets ---> serverroot/bluewidgets/(htaccess 301 redir)---> serverroot/widgets/
nice.widgets ---> serverroot/nicewidgets/(htaccess 301 redir)---> serverroot/widgets/

But... I don't know how to do it. Every example I found is very confusing...

Thanks in advance,

Enrique

 

eflouret




msg:1509377
 12:47 pm on May 7, 2005 (gmt 0)

Anybody?

Eugenios




msg:1509378
 7:04 pm on May 9, 2005 (gmt 0)

It seems that is a tough question, or I didn't explain myself correctly...

jd01




msg:1509379
 7:50 pm on May 9, 2005 (gmt 0)

Sorry, didn't notice this one went unanswered and domain 'pointing' is not my cup-o-tea.

Since the domains are 'pointed' to your directory, I am assuming they must be subject to the same .htaccess as is present on the main www domain. If this is the case, you should be able to 'bounce' the sub-domain requests to the www version with the following (or, something similar)

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

Consequently, this will redirect any non-www widgets.com requests to www.widgets.com also. If you do not wish for this to happen, you will need to add a second condition.

[OR]

Contact your host and ask the pointing of the domains be changed to individual sites. After your domains are 'pointed' correctly, you can very simple add a .htaccess file to the sub-domains with the following:

RewriteEngine on
RewriteRule ^(.*)$ http://www.newsite.com/$1 [R=301,L]

There are some detailed explainations of what this does in some other very recent threads, so I will let you decide if you want to know more.

Please note: Since you are rewriting all requests there is no need to set up any directory structure.

Hope this helps.

Justin

Eugenios




msg:1509380
 1:35 am on May 16, 2005 (gmt 0)

Thanks Justin!

I have a dedicated server account and can manage where to point domains myself.

I will check both options to see which is best for me.

Thanks again for your reply.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved