domain-to-domain almost working

Using a single web hosting account to host multiple sites

domain-to-domain almost working

Postby Fumigator » Wed Apr 18, 2007 7:39 pm

I'm an idiot with mod_rewrite, but I've managed to learn enough to get a domain-to-domain redirect almost working how I want. I've come up with this:


Code: Select all
Options +FollowSymLinks
RewriteEngine on

RewriteCond %{HTTP_HOST} ^(www\.)?alpha\.com$ [NC]
RewriteRule ^(.+)/(.+)$ http://www.bravo.com/codedir/test/$2 [NC,QSA,L]


Which works, but sends the redirection to the browser's URL box even though I do not use the "R" directive. How can I make this redirect silent so the browser shows www . alpha . com?
Fumigator
 
Posts: 4
Joined: Wed Apr 18, 2007 7:18 pm

Postby richardk » Fri Apr 20, 2007 9:32 am

If those domains go to different servers or document roots* the only way to do it is with mod_proxy by adding the P flag.

If it's on the same server and document root* remove the domain from the path.

* The same document root means alpha.com goes to /root and bravo.com goes to /root/some/subdir. If that's not a good explaination, post the document roots.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby Fumigator » Fri Apr 20, 2007 11:14 am

They are on the same server and document root. They are "sister" domains-- it looks like this:

/home/account/public_html/alpha
/home/account/public_html/bravo

The hosting company redirects www.alpha.com to /home/account/public_html/alpha and redirects www.bravo.com to /home/account/public_html/bravo.

I've tried RewriteRule ^(.+)/(.+)$ /../bravo/codedir/test/$2 [NC,QSA,L], the idea being I move up one level in the structure and then down to bravo/codedir/test, but that did not work. (I'm not at my computer so I'm afraid I can't give you more details on what that did until later)

I also tried the [P] directive but that broke the redirect entirely-- presumably because the mod_proxy is not there(?)... but yeah I'd just as soon do it without the proxy directive if possible.

Thank you Richardk for your help!
Fumigator
 
Posts: 4
Joined: Wed Apr 18, 2007 7:18 pm

Postby richardk » Fri Apr 20, 2007 11:40 am

/home/account/public_html/alpha is alpha.com's document root. You can't go above it with mod_rewrite.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby Fumigator » Sun Apr 22, 2007 6:56 pm

Ahh ok well then, thanks for that answer. I will try to get that [P] directive working, and then I'll come beg for more help when I fail :D
Fumigator
 
Posts: 4
Joined: Wed Apr 18, 2007 7:18 pm


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 17 guests

cron