conditional domain rewrite

Using a single web hosting account to host multiple sites

conditional domain rewrite

Postby twistedsymphony » Fri Mar 30, 2007 12:27 pm

I've done a few simple mod rewrites in the past but I'm really scratching my head over this one and I'm not entirely sure it's even possible...

Basically there are 2 domains on the same server

Walter.com goes to:
Walter.com

Nikki.com goes to:
Walter.com/Nik

Walter.com also has a directory:
Walter.com/Walt

I want to go to
Nikki.com/Walt but really be viewing Walter.com/Walt

But ONLY if the user followed a link from Nikki.com
If the user started at Walter.com I want the url to remain as Walter.com

Essentially there are 2 domains that share a directly, but that's all they share.

I know this is possible for when the visitor first enters Nikki.com/Walt but if I have a rewrite conditional on the referrer domain (Nikki) will it stick as they browse around or will it no longer rewrite after they follow the first link?
twistedsymphony
 
Posts: 3
Joined: Fri Mar 30, 2007 12:13 pm
Location: Almost Canada

Postby richardk » Fri Mar 30, 2007 2:06 pm

Mod_rewrite can't rewrite to higher directories (from /Nik/Walt/* to /Walt/*), so you'll probably need mod_proxy too.

This might work
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_REFERER} ^((www\.)?nikki\.com(/.*)?)?$ [NC]
RewriteRule ^walt(/(.*))?$ http://www.walter.com/walt/$2 [P,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby twistedsymphony » Sun Apr 01, 2007 12:02 pm

twistedsymphony
 
Posts: 3
Joined: Fri Mar 30, 2007 12:13 pm
Location: Almost Canada

Postby richardk » Sun Apr 01, 2007 1:42 pm

What URL are you going to?

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?nikki\.com$ [NC]
RewriteCond %{HTTP_REFERER} ^((www\.)?nikki\.com(/.*)?)?$ [NC]
RewriteRule ^walt(/(.*))?$ http://www.walter.com/walt/$2 [P,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby twistedsymphony » Wed Apr 04, 2007 6:05 am

After trying that and playing with it for a couple of days I couldn't get it to work right... I've changed the layout of the domains.

I also realized that I forgot to mention both of these domains have a "-" character in them :-?

basically nikki and walter both point to the same directory now which is a wiki. If it makes a difference maybe we should refer to them as nikki-site .com and walter-site.com

now I'd like to point to an alternative main page for one of the domains.

so

walter-site.com -> walter-site.com/index.php?title=Main_Page
^the wiki does that automatically
but when nikki-site.com tries to load that page I want to rewrite it to:

nikki-site.com/index.php?title=Nikki-Site
twistedsymphony
 
Posts: 3
Joined: Fri Mar 30, 2007 12:13 pm
Location: Almost Canada

Postby richardk » Wed Apr 04, 2007 8:55 am

Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?walter-site\.com$ [NC]
RewriteRule ^$ /index.php?title=Main_Page [QSA,L]

RewriteCond %{HTTP_HOST} ^(www\.)?nikki-site\.com$ [NC]
RewriteRule ^$ /index.php?title=Nikki-Site [QSA,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 25 guests

cron