Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Redirect from a domain to another
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

egemini
Starting Member

Sweden
31 Posts

Posted - 06 March 2001 :  12:53:46  Show Profile  Send egemini an ICQ Message
I have two domains pointing to the same directory. I would like to direct all visitors that enters on one of the domains to the other. Is there a way to check wich domain the visitor is entering my side with?



Doug G
Support Moderator

USA
6493 Posts

Posted - 06 March 2001 :  14:46:59  Show Profile
Something like this should work

<%
Dim sDomain
sDomain = Request.ServerVariables("HTTP_REFERER")
If InStr(sDomain, "domain1.com") Then Response.Redirect "domain1.com"
If InStr(sDomain, "domain2.com") Then Response.redirect "domain2.com"
...
...
%>


======
Doug G
======
Go to Top of Page

egemini
Starting Member

Sweden
31 Posts

Posted - 06 March 2001 :  17:56:47  Show Profile  Send egemini an ICQ Message
Forgive me for beeing stupid, but how do I translate this to a simple Java script that runs when you enter the site?



Go to Top of Page

redbrad0
Advanced Member

USA
3725 Posts

Posted - 06 March 2001 :  18:34:06  Show Profile  Visit redbrad0's Homepage  Send redbrad0 an AOL message
if you have an NT Server this ASP script works perfect. What I do on one of my servers is this...

[code]
<%
sDomain = Request.ServerVariables("HTTP_REFERER")
If InStr(sDomain, "domain1.com") Then Response.Redirect "www.basesite.com/domain1"
If InStr(sDomain, "domain2.com") Then Response.Redirect "www.basesite.com/domain2"
%>

Brad
Go to Top of Page

Doug G
Support Moderator

USA
6493 Posts

Posted - 06 March 2001 :  19:10:34  Show Profile
The code runs on the server, not on the client. And it should be slightly altered to make the If InStr(...) > 0 (to be safe).

Here's what happens on your asp-enabled site, assuming default.asp is the default web page for your site and has the above code in it.

Your site visitor plonks "www.site1.com" into their browser. This calls up the page default.asp on the server. Since the page extension is .asp, that prompts the server to send the page to an isapi filter (a dll file) that process the .asp page. The asp.dll file executes the above code in the server, discovering that HTTP_REFERER is "www.site1.com". The code tests HTTP_REFERER to see what it is, and if it matches causes a 'response.redirect' to happen on the server.

The response.redirect sends back an HTTP error 304, 'object moved' to the client's browser with the redirected url, and the browser then goes to the redirected page. You don't need any script on the browser to make this happen.

HTH


======
Doug G
======
Go to Top of Page

MasterFraud
Starting Member

8 Posts

Posted - 22 March 2001 :  00:31:44  Show Profile
Also have alook at one of my examples on my site

'how to redirect based on domain'
http://designbliss.com.au/asp/examples/0001-domainredirect.asp

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.32 seconds. Powered By: Snitz Forums 2000 Version 3.4.07