Forum Moderators: open

Message Too Old, No Replies

ASP Redirect Question

Resolving to second URL in subdirectory

         

gatitonegrito

3:45 am on May 21, 2002 (gmt 0)



For my multilingual site, I have recently aquired an additional URL that I want to point to a subdirectory of my domain, for the purpose of improved marketing. I will be using similar, but not the same content, so I am not worried about duplicate content penalties.

However, is the following redirect procedure, which is recommended by my host, the best one?

My goal is to have no problem with spidering and to see my new url getting ranked.

----------
Using ASP code, you can detect which URL a person is browsing to your site with, and redirect them to the appropriate place on your site. Here is some example code that will do the job, put this at the very top of an .ASP page, before any HTTP tags:
<%
sname = Request.ServerVariables("SERVER_NAME")
sname = ucase(sname)
if InStr(sname,"DOMAIN1") <> 0 then
response.redirect "subdirectory to go to"
elseif InStr(sname,"DOMAIN2") <> 0 then
response.redirect "2nd subdirectory to go to"
elseif........
end if

Make sure that the domains in the InStr commands are capital letters. For example, suppose you have two domains, apple.com and banana.com, pointing to the same web site. On this site there is an "appledir" subdirectory (or sub-web) and a "bananadir" subdirectory. Then the code will look like this:

<%
sname = Request.ServerVariables("SERVER_NAME")
sname = ucase(sname)
if InStr(sname,"APPLE") <> 0 then
response.redirect "appledir"
elseif InStr(sname,"BANANA") <> 0 then
response.redirect "bananadir"
end if

If you have only two domains and you still need the primary domain to poin to the root of the site then you can use this code:

<%
sname = Request.ServerVariables("SERVER_NAME")
sname = ucase(sname)
if InStr(sname,"DOMAIN2") <> 0 then
response.redirect "domain"
else
response.redirect "index.html"
end if

ferrari360

4:38 am on May 21, 2002 (gmt 0)

10+ Year Member



I've got an .asp site where I work out the domain they came in on in global.asa and then set a session variable for that user - I then display the formatting, logo's and content for that domain. You could use a similar method to determine which content to feed depending on the domain - because global.asa fires each time a session is started it also works when a spider crawls the site (e.g. not one continous session).

To date google has not had a problem indexing my domains utilizing this structure.

gatitonegrito

4:41 am on May 21, 2002 (gmt 0)



that's great information, thanks.