Forum Moderators: open

Message Too Old, No Replies

shared hosting, global.asa to redirect non-firefox users?

         

AlwaysSayNever

12:00 pm on Apr 19, 2005 (gmt 0)

10+ Year Member



I have a "free" shared hosting account to play with a free asp application. However since its asp it obviously won't like my .htaccess for apache. I've googled till I turned blue but I cannot find *actual* code snippets to paste into global.asa to redirect non-firefox users to another document (that will politely suggest they consider switching to firefox). Syntax documents are of no help since I'm not as asp person. :)

Will someone here kindly direct me to such a code snippet?

thanks much

AlwaysSayNever

12:08 pm on Apr 19, 2005 (gmt 0)

10+ Year Member



{post editing does not appear to be an option}

Culling from elsewhere this is as far as I can get

<script language="vbscript" runat="server">

sub Session_OnStart
dim remote_agent
remote_agent = request.ServerVariables("HTTP_USER_AGENT")
If remote_agent!= ^Mozilla/5.0.*$
Then Response.Redirect("http://mysubdomain.example.com/tryfirefox.asp")
End If
end sub

</script>

this

^Mozilla/5.0.*$
is straight from my .htaccess as I don't know the asp equivalent for "begins with" (^) and "ends with anything" (.*$). I also assumed that

!=

was "does not equal"

can "Response.Redirect" point to a document instead of a full url?

thanks even more

[edited by: Xoc at 7:05 am (utc) on April 26, 2005]
[edit reason] Use example.com for examples [/edit]

Easy_Coder

1:04 pm on Apr 19, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can use the Instr function to check for this ^Mozilla/5.0.*$ but it's not as flexible because you won't be able to wildcard (.*) the point version like you've done in your .htaccess file.


remote_agent = Request.ServerVariables("HTTP_USER_AGENT")
If InStr(1, remote_agent, "Mozilla/5.0.") = 0 Then
Response.Redirect "http://mysubdomain.example.com/tryfirefox.asp"
Else
' Found something close to Mozilla/5.0.*
End If

If you absolutely require the wildcard search then look into a regular expression.

[edited by: Xoc at 7:05 am (utc) on April 26, 2005]
[edit reason] Use example.com for examples [/edit]