Forum Moderators: open
The reason I ask this is because I would like to take action (301 redirect to a url) within the Session_OnStart event (in global.asa). If the session is maintained and the bot makes multiple requests, I believe the Session_OnStart event will only fire on the first request...so only the first request will be properly redirected while the other requests are served a page.
Does anyone know how this is handled?
I'm not sure exactly what you are trying to do, but I'd guess you could accomplish what you want to do by doing this... (This isn't code, but you can easily convert the train of thought to code...)
If mid(user-agent,1,8) = "googlebot" and Application("GoogleSession") = False then Application("GoogleSession") = True
If Googlesession = True then do or don't redirect or whatever.
Unfortunately, you'd have to put this on every page (probably in an SSI so you can tweak it and have it update the whole site) but depending upon exactly what you are trying to do, something along these lines would work - App variables can be passed to bots.
Hope that at least gets you thinking, if not solving the problem altogether.
G.
Also Grumpus...thanks for the snippet but it actually is the other way around...but let me run the situation by you (this is somewhat long...my apologies).
As stated in the thread [webmasterworld.com ] my staging server has recently been indexed. Since ALL of the staging server content is published to the main server, this resulted in duplicated content. One of the suggestions by many in the thread is to 301 redirect to the appropriate server.
In IIS, I can set a global redirect for the website to a specified url (Properties -> Home Directory -> A redirection to a url). There are two problems however.
So, my second solution was to intercept the request in Session_OnStart and set the response to "301 Moved Permanently". This is great unless the session persists. For example, if a request goes to staging/page1.asp, I can redirect to main/page1.asp. But if you keep the browser open, then request staging/page2.asp, you get staging/page2.asp. This is OK with me, as long as ALL spiders are properly redirected to main on every request...that was my original (yet misleading) question in this thread.
So if you (or anyone else) could give me your opinion for any or all of the following three questions it would be a great help:
I really think that's a server issue, it's a trivial thing to do on other Web servers and it's the right thing to do.
> the response from the server is "301 Error", not "301 Moved Permanently".
I can't imagine any search robot paying attention to the text. The server software is quite wrong to do this in my opinion, but I'd eat my hat if it mattered in Google.
If you want to give a 301 response instead of the response.redirect 302 use this addheader code:
<%
Response.Status = "301 Moved Permanently"
Response.addheader "Location", "http://www.newdomain.com/newurl/"
Response.End
%>