This forum has been moved here:
Helicon Tech Community Forum

ISAPI_Rewrite 3.0 (Forum Locked Forum Locked)
 Helicon Tech : ISAPI_Rewrite 3.0
Subject Topic: Redirect specific path to another domain
Author
Message |
GeekGirl
Newbie


Joined: 21 October 2009
Location: Australia
Posts: 18
Posted: 22 July 2011 at 3:33am

I want to redirect clients (different domains) to a central CMS but make it appear as though the CMS is on their own website/domain (all websites, including the CMS, are hosted on the same server).

For example:
http://www.clientdomain.com.au/admin (or admin/) > http://www.mydomain.com.au/admin/default.asp?idsite=3
(note: if posssible, I'd like to retain the visible client domain name in the address bar)

So I assume .htaccess needs to be configured on both the clientdomain and mydomain???

I was planning to manually setup the .htaccess on the client domain to set 'idsite', for example:
RewriteRule ^admin(.*) http://www.mydomain.com.au/admin/(.*) [CL,U,QSA,P]
RewriteRule ^admin http://www.mydomain.com.au/admin/default.asp\?idsite=3 [CL,U,QSA,P,L]
(Not sure if this is correct. It works but the images/css links are all broken)

I'm not sure how to configure the .htaccess for the cms hosting domain (mydomain.com.au/admin)??? I was hoping to make this variable so that it doesn't have to be configured for all clients. Use wildcards where 'clientdomain' needs to go?

I really have no idea what I'm doing here. I've been trying to work by example (guess using examples from forum/Google) for hours.

Thanks in advance for any help!
GG

Back to Top
 
GeekGirl
Newbie


Joined: 21 October 2009
Location: Australia
Posts: 18
Posted: 22 July 2011 at 6:53am

I've since discovered that it's called "rewriting to a proxy". I can get the redirection happening but asp at 'mydomain/admin' doesn't work plus images/css links are broken. I've added 'base ref' to my header but the page doesn't load probably. It's like the page is trying to pull images from 'clientdomain' instead of 'mydomain' and I suspect the problem is more complex than baseref.

Here's what I've currenltly got in the .htaccess file on the clientdomain:

RewriteProxy ^admin(.*) http://www.mydomain.com.au/admin$1

This of course doesn't include the 'idsite' reference. I don't know how to incorporate that???

I'm also not sure if the .htaccess on mydomain is causing problems. I use URL rewrites on nearly all my sites to turn lengthy asp urls+querystrings into SEO friendly paths. I love it! Should I have something in their to cater for this redirection once there?

Pleeeese help!

Back to Top
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 25 July 2011 at 4:53am

Hello,

What kind of paths to images and .css are there at your page? realtive?
You need to change your links to ba absolute or root-relative, than everything will work.

Regarding the rules in httpd.conf and .htaccess: please, see the article about processing config files.

Regards
Andrew
Back to Top
 
GeekGirl
Newbie


Joined: 21 October 2009
Location: Australia
Posts: 18
Posted: 28 July 2011 at 1:21am

Thanks Andrew, I've gotten a bit further now. After experimenting with absolute paths I've settled with using relative paths (css,img) with "base href" set to "/admin/". The destination (mydomain) is now as it shoud - CSS, images linking, etc.

My questions now is, how do I rewrite to proxy AND carry the "idsite" at the same time?

I'm currently hard-coding the "idsite" at the destination (mydomain) to test that everything else is working. My database serves only content related to the idsite specified. But obviously I need this to be dynamic; carried from the original url.

Thanks,
GG

Back to Top
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 28 July 2011 at 4:26am

To create a proxy rule you need to place the following in .htaccess of the web-site you're willing to make request in browser to:

Code:
RewriteRule ^admin(.*)$ http://www.mydomain.com.au/admin$1 [QSA,NC,P,L]


Not really sure that I understood you right: "My questions now is, how do I rewrite to proxy AND carry the "idsite" at the same time?".
Basically in you need to pass both everything after '/admin/XXXX' AND querystring, than QSA flag is what you need.
You can provide multiple examples in case I didn't get you right.

Regards
Andrew
Back to Top
 
GeekGirl
Newbie


Joined: 21 October 2009
Location: Australia
Posts: 18
Posted: 16 August 2011 at 11:20pm

Thanks Andrew. Let me start over and try to explain again (sorry, I'm probably not using the correct terminology here!)...

I want all clients to use the URL:
www.[clientdomain].com.au/admin and appear to stay on their domain, but the CMS actually resides at: 
www.cms.com.au/admin

Here's what I currently have on the client domain (.htaccess):
RewriteCond http://www.clientdomain.com.au/admin
RewriteProxy ^admin(.*) http://www.mydomain.com.au/admin/default.asp\?client=companyname [QSA,NC,P]

Using a querystring passed from the original URL set in the .htaccess on the client domain (eg: client=companyname, see sample above) the CMS (classic asp) will identify which client and serve the appropriate site data.

All admin/CMS files reside at: www.mydomain.com.au/admin
The header of the CMS currently uses:
baseref=http://www.mydomain.com.au/admin

This all works fine to initially redirect; however links/forms are set by baseref: www.mydomain.com.au/admin/... so the URL then changes. I want the URL to appear as though it's being served from THEIR domain. I don't want the client to know that they have been redirected. Is it possible to retain the original URL in the address bar while serving data and pages from another domain?

Thanks!
Penny

Back to Top
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 17 August 2011 at 9:18am

Thank you, sounds very clear.
Please, try to modify the baseref as following:baseref=/admin, so that the HOST will be applied automatically by browser.

Your rule needs some modifications:

Code:
RewriteCond %{HTTP:Host} ^www\.clientdomain\.com\.au$ [NC]
RewriteRule (admin/?.*)$ http://www.mydomain.com.au/admin/default.asp?client=companyname [QSA,NC,P]

NOTE: We need to know where to redirect everything after admin/XXXX. For right now this rule will work only for /admin/ page, everything after /admin/
will be ignored.


Regards
Andrew
Back to Top
 
GeekGirl
Newbie


Joined: 21 October 2009
Location: Australia
Posts: 18
Posted: 18 August 2011 at 12:30am

Thanks for your help Andrew.

1. I've inserted the code you provided into .htaccess on the client site
2. changed the baseref on the admin site and made img/css links absolute. It all appears to look good.

Here's an example:
client site: http://www.updatewizard.com.au/wizard

Not sure what to do next? I want the user to think they are still on their domain (in this example: updatewizard.com.au).

I currently get error: "The page isn't redirecting properly" (or similar, depending on which browser).

Thanks again!

 

Back to Top
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 18 August 2011 at 7:55am

See, you request http://www.updatewizard.com.au/wizard and get rewritten to /wizard/default.asp?client=updatewizard
So, basically the rule works as expected, but we need to proxy it to www.OTHERSITE.com/wizard/default.asp?client=updatewizard.
IS it correct?

We have logging function. You can enable logging and provide the rewrite.log for the testing request.
Logging issues described in FAQ

Regards
Andrew
Back to Top
 
GeekGirl
Newbie


Joined: 21 October 2009
Location: Australia
Posts: 18
Posted: 18 August 2011 at 8:03am

Yes, I think that's correct. I want the url to still read www.clientdomain.com.au/wizard but the pages/asp/data to be located at www.mydomain.com.au/wizard. Rather than installing a CMS on each client site I'm trying to create a central system but make it look seamless.

I'm on a shared host. Not sure how to enable logging. Is that possible via .htaccess? 

Back to Top
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 22 August 2011 at 4:12am

No, you cannot enable logging from .htaccess. You do it from httpd.conf and it enables logging for the whole server, so shared server services never do that.

Please, provide the rule that you use at it is. The rule seems to work, but doe not proxy, which is strange.

Regards
Andrew
Back to Top
 
GeekGirl
Newbie


Joined: 21 October 2009
Location: Australia
Posts: 18
Posted: 22 August 2011 at 7:53am

Hi Andrew,

This is the full contents of my .htaccess file at www.updatewizard.com.au:

Code:

# Block external access to the httpd.ini and
httpd.parse.errors files
RewriteRule /httpd(?:\.ini|\.parse\.errors) / [F,I,O]

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP:Host} ^www\.updatewizard\.com\.au$
[NC]
RewriteRule ^wizard/?.*$
http://www.webdesignnewcastle.com.au/wizard/default.asp?
client=updatewizard [QSA,NC,P]

Note: I tried (wizard/?.*)$ but it didn't work

This redirects perfectly but it doesn't get any further.

My baseref within all pages at
webdesignnewcastle.com.au/wizard is:
<base href="/wizard/">
Note: I've tried adjusting baseref to "wizard/" and other
variations.

If the above looks ok it could be a problem with my ASP
code?

I've tried a zillion combinations with the .htaccess and
my code. I'm pulling my hair out!

If you go to www.updatewizard.com.au/wizard you can see
it in action.

Thanks again for your help.
Back to Top
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 23 August 2011 at 5:03am

Lets simply try the testing rule to make sure you have proxying enabled.
Try smth like:

Code:
RewriteRule ^test-test$ http://www.google.co.uk/ [NC,P,L]


This must show you google search form under www.updatewizard.com.au/test-test. I've shosen google.co.uk because .com usually forces redirect, not proxy.

Regards
Andrew
Back to Top
 
GeekGirl
Newbie


Joined: 21 October 2009
Location: Australia
Posts: 18
Posted: 23 August 2011 at 6:11am

No, it didn't work: "Page cannot be found".

Is it likely that proxying can be enabled for specific
domains or only server wide? I'm on a shared host - options
may be limited.
Back to Top
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 25 August 2011 at 2:47am

Depends on your server provider. You can show this part of documentation to your server provider.

Regards
Andrew
Back to Top
 
GeekGirl
Newbie


Joined: 21 October 2009
Location: Australia
Posts: 18
Posted: 12 September 2011 at 12:28am

I've since asked my host to enable proxying (which they
tell me they now have). I've setup a tests:

The code below redirects from
www.updatewizard.com.au/wizard. Once there the links on
the page don't work:
Code:

RewriteCond %{HTTP:Host} ^www\.updatewizard\.com\.au$
[NC]
RewriteRule ^wizard/?.*$
http://www.webdesignnewcastle.com.au/wizard/default.asp?
client=updatewizard [QSA,NC,P,L]
#PROXY TEST:
RewriteRule ^test-test$ http://www.google.co.uk/ [NC,P,L]



The 2nd test links from www.websharp.com.au/wizard. The
only difference is I've removed the P from the
RewriteRule

:
Code:
RewriteCond %{HTTP:Host} ^www\.websharp\.com\.au$
[NC]
RewriteRule ^wizard/?.*$
http://www.webdesignnewcastle.com.au/wizard/default.asp?
client=websharp [QSA,NC,L]
#PROXY TEST:
RewriteRule ^test-test$ http://www.google.co.uk/ [NC,L]


Both examples/test redirect ok, but the first one stops
at that page - none of the links work (or maybe the page
redirect loops?). The links work on the 2nd but the
'real' URL is displayed (I want it to remain as
'websharp.com.au').

I've also retained the GoogleUK test links. Again, the
first has [NC,P,L] attached to rule but 2nd only has
[NC,L]

Edited by GeekGirl - 12 September 2011 at 12:29am

Back to Top
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 12 September 2011 at 4:59am

Sure, first one is the one you need - proxy. Second - simple redirect.
What we need - to make the forst one work.

Tell me, do you have this one working? I didn't understand.
Code:
RewriteRule ^test-test$ http://www.google.co.uk/ [NC,P,L]


If yes, I'd like to see the request-example(clicable) for:
Code:
RewriteCond %{HTTP:Host} ^www\.updatewizard\.com\.au$ [NC]
RewriteRule ^wizard/?.*$ http://www.webdesignnewcastle.com.au/wizard/default.asp?client=updatewizard [QSA,NC,P,L]


Regards
Andrew
Back to Top
 
GeekGirl
Newbie


Joined: 21 October 2009
Location: Australia
Posts: 18
Posted: 12 September 2011 at 5:24am

Thanks again Andrew.

I have the first one redirecting but images don't appear correctly:
http://www.updatewizard.com.au/test-test

Here is the clickable example for the request:
http://www.updatewizard.com.au/wizard
(redirects ok but stops there)

My hosting provider took quite a while to investigate my request when I asked if proxying was enabled. It's quite possible that it is not configured properly. Can you tell from these test links?

Cheers, GG.

FYI: The formatting of my posts is weird when using Google Chrome. Test wraps in weird places and inserting code/links is problematic. Not sure if you're aware of this. I've now switched it IE9 which seems to working much better.

 

Back to Top
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 12 September 2011 at 5:49am

Well, proxying work. Your links do not work, which is understandable - the rule we use is hardcoded only for the first page /wizard/, as it is pointing at
http://www.webdesignnewcastle.com.au/wizard/default.asp?client=updatewizard. Where do we need to point /wizard/page1.asp, for example?


Regards
Andrew
Back to Top
 
GeekGirl
Newbie


Joined: 21 October 2009
Location: Australia
Posts: 18
Posted: 12 September 2011 at 5:59am

Once redirected I want the domain to still appear as if it was at www.updatewizard.com.au. For example:

www.updatewizard.com.au/page1.asp,
www.updatewizard.com.au/page2.asp, etc...

Is that possible? I obviously have access to both redirected domains.

All my clients websites are hosted on the same server (reseller hosting which I manage). Currently I install a seperate version of my CMS for each client. To steamline maintenance I want to centralise so ALL of my clients use the same database/CMS but when they login it "appears" to them to be a unique and personalised CMS.

Cheers,
Penny


 

Back to Top
 

Page of 2 Next >>
 
Printable version Printable version