SuperNoob: redirect entire domain

Using a single web hosting account to host multiple sites

SuperNoob: redirect entire domain

Postby starkmann » Wed Feb 14, 2007 10:35 am

I'm very sorry for this very noob question. I feel like I have read the answer but just don't understand it.

So I have four domains
Alice.us
Bob.org
Cindy.com
Cindy.net
(yep the last two have the same name with a different extension)
They all point to my home directory which is where Alice's content resides. So if you put in any of the address you end up looking at the Alice.us content.
Bob's content is at Alice/Bob and Cindy's content is at Alice/Cindy.
What do I need to do so that when you type in Bob.org you go to Alice/Bob (in the file directory) but see in the browser bar Bob.org. The same question regarding Cindy's content.
I have been playing with this for a couple days and only break things when I try. It seems that most tutorial teach me how to cover up the subdirectories but none of them tell me how to totally rewrite the domain. Here is my latest try.

Code: Select all
RewriteEngine On
RewriteCond %{HTTP_HOST} http://Cindy.com$ [NC]
RewriteCond %{REQUEST_URI} http://Alice.us/Cindy/.*$
RewriteRule ^(.*)$ http://Cindy.com/$1 [L]


When I put http://Cindy.com into my browser all I get is http://Alice.us in response.
I realize that I would need to do this a couple more times , once for each domain, but I'll go one at a time.
I would appreciate any help. thanks
starkmann
 
Posts: 9
Joined: Wed Feb 14, 2007 9:57 am

Postby richardk » Wed Feb 14, 2007 10:58 am

In a .htaccess file in alice.com's document root:
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^(www\.)?bob\.org$ [NC]
RewriteRule ^(.*)$ /bob/$1 [QSA,L]

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^(www\.)?cindy\.(com|net)$ [NC]
RewriteRule ^(.*)$ /cindy/$1 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby starkmann » Wed Feb 14, 2007 4:00 pm

HOORAY!!! It worked. Thanks so very much. I wouldn't have gotten to that answer on my own anytime in the near future.
starkmann
 
Posts: 9
Joined: Wed Feb 14, 2007 9:57 am

Postby starkmann » Thu Feb 15, 2007 11:06 am

I've been playing with this a bit more. It's odd. If I request anything more precise than the basic URL it loses the logic applied by .htaccess. So http://bob.org shows me the content of alice/bob/index.html as expected. However if I actually put in http://bob.org/index or if I click on any link in the index to take me to another file in the same directory, I get 404ed. If I type in http://bob.org/bob/index.html or another file, then I get the content. Do I need to add another .htaccess file to the directory bob?
starkmann
 
Posts: 9
Joined: Wed Feb 14, 2007 9:57 am

Postby richardk » Fri Feb 16, 2007 7:50 am

What are the links in the source of the page like? Do they contain /bob?

You should add
Code: Select all
RewriteCond %{DOCUMENT_ROOT}/bob%{REQUEST_URI}/ -d [OR]
RewriteCond %{DOCUMENT_ROOT}/cindy%{REQUEST_URI}/ -d
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]

after
Code: Select all
RewriteEngine On


Do I need to add another .htaccess file to the directory bob?

No.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby starkmann » Sun Feb 18, 2007 3:31 am

Sorry about the slow response.

To answer your question re: the link structure. It varies right now. I added your new bit of code and when I go to bob.org and click on a link with the path bob.org/picturepage.html it works great now. That is fantastic.
When I got to cindy.com (I should probably mention that this is a wordpress blog) it shows up. It had been setup as cindy.com/cindy. I fixed that and it halfway broke it. I'm pretty sure I'm into a wordpress problem now. I think it may call for a clean install. 75% of it seems to work great but something internal to wordpress is not calling the cindy/cp-includes/themes/ content correctly.

I really appreciate your help I'll post back if I need more otherwise, I think I'm in lurker mode here. There is a lot of really cool stuff to learn here.
Thanks again.
starkmann
 
Posts: 9
Joined: Wed Feb 14, 2007 9:57 am

Postby starkmann » Tue Feb 20, 2007 8:14 am

Is it possible my host has turned off inheritance some how. I seem to be having problems when I rely on it.
starkmann
 
Posts: 9
Joined: Wed Feb 14, 2007 9:57 am

Postby richardk » Tue Feb 20, 2007 10:09 am

something internal to wordpress is not calling the cindy/cp-includes/themes/ content correctly.

What are the paths in the HTML source like? Maybe they're wrong because the document root and PHP_SELF are "wrong" because of the mod_rewrite.

Is it possible my host has turned off inheritance some how.

There aren't settings like that for mod_rewrite. And it would be a pretty bad host if they did things like that anyway. But you could try this
Code: Select all
RewriteOptions inherit
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby starkmann » Tue Feb 20, 2007 10:15 am

Thanks for all your help Richard, I'm still struggling

I placed your code right below the ReWrite Engine On line
I have:

Code: Select all
Options +FollowSymLinks

RewriteEngine On
RewriteOptions inherit


RewriteCond %{DOCUMENT_ROOT}/AmosFamily%{REQUEST_URI}/ -d [OR]
RewriteCond %{DOCUMENT_ROOT}/trainingsyndicate%{REQUEST_URI}/ -d
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^(www\.)?amosfamily\.org$ [NC]
RewriteRule ^(.*)$ /AmosFamily/$1 [QSA,L]

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^(www\.)?trainingsyndicate\.(com|net)$ [NC]
RewriteRule ^(.*)$ /trainingsyndicate/$1 [QSA,L]


I wrote a crappy little html document that shows the issue I am encountering.

I hope it makes sense and is easy for you. I appreciate your help.
If it's just a lost cause, let me know.
starkmann
 
Posts: 9
Joined: Wed Feb 14, 2007 9:57 am

Postby richardk » Tue Feb 20, 2007 11:02 am

I placed your code right below the ReWrite Engine On line

Try it in a .htaccess file in the domain subdirectories.

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{DOCUMENT_ROOT}/domainA%{REQUEST_URI}/ -d [OR]
RewriteCond %{DOCUMENT_ROOT}/domainB%{REQUEST_URI}/ -d
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^(www\.)?domainA\.org$ [NC]
RewriteRule .* /domainA%{REQUEST_URI} [QSA,L]

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^(www\.)?domainB\.(com|net)$ [NC]
RewriteRule .* /domainB%{REQUEST_URI} [QSA,L]


If it still doesn't work, replace QSA with R and see where you get redirected, maybe that'll give some clue.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Next

Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 103 guests

cron