Forum Moderators: phranque

Message Too Old, No Replies

www - non-www redirect on virtual hosting

Not another 301 query!

         

oddsod

5:28 pm on Sep 8, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sorry if this question is repeated guys but I've got a whole lot of 301 related posts flagged (including this great one [webmasterworld.com] by jd01) but can't find the answer.

I have a friend with several sites hosted on a virtual hosting i.e. he has a shared hosting account at Westhost with the facility of adding other sites to his account.

So, he added two sites, and created a site2 folder and site3 folder and dumped all his site2 and site3 files in there and they resolve OK i.e. you type site1.com and you get the expected stuff in your browser window. But Google has now indexed those sites as directories of site1. Google has picked up site1.com/site2/content.htm and site1.com/site3/content.htm.

How does he separate this in .htaccess? And have them all show up with the "www" version only?

TIA

benevolent001

5:43 pm on Sep 8, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



am also with same host but never noticed this.

i am too eager to have some insight into this issue waiting for jdMorgan to resolve..

have u asked this onto there own forums? may be there tech support can answer it

jdMorgan

3:51 pm on Sep 10, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Using a RewriteCond, examine %{THE_REQUEST}, and redirect those subdomain-subdirectory requests to the canonical subdomain.

Use of this technique avoids the 'infinite' redirection loop that can result if you use a simple redirect.

Jim

oddsod

2:44 pm on Sep 11, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



jdMorgan, thanks for your reply but sorry, for Apache idiots like me that doesn't make any sense. :( Is there a thread around with the exact code?

Also, I understand sub-domains as taking the form subdomain.mysite.com. I don't know if my OP suggested there were subdomains but there aren't.

Quite simply there are three sites called site1.com, site2.com and site3.com. Because they are all hosted on the same account you get one single FTP login and one single directory tree into which you need to put the files for all three sites. So, in the "main" folder you post the files for site1.com and within that folder you create a site2 and site3 folder for files relating to those other sites. Your control panel allows you to associate each domain to the folder for that domain. So when a visitor types ww*.site2.com/content.htm then the file that's in the site2 folder with the name "content.htm" is served up.

The problem is that you can also access that file by typing site1.com/site2/content.htm. And Google is doing just that. I'm hoping to solve that by having a htaccess that redirects site1.com/site2/content.htm to htt*://ww*.site2.com/content.htm. And to do the same for site3.com

Apologies in advance if it hasn't been explained very well.

oddsod

4:07 pm on Sep 13, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Nobody? :(