Using Request.ServerVariables("HTTP_REFERER")

Posted on 2009-02-12
Last Modified: 2012-06-27
Hello everyone

I have a piece of code that came from EE which I sort of understand. However, I don't know how to expand on it.

The code is:

<% If Right(Request.ServerVariables("HTTP_REFERER"),24) = "20yearsTrustMessages.asp" Then

Response.Write("<div id='goBack'><a href='javascript:back()' class='goBack'>[ Return to the previous page ]</a></div>")

End If %>

It works fine if referer is '20yearsTrustMessages.asp' but we now use Recordset Paging and the extension can be followed by '?offset=...'. with the figure after the = varying (-1, 0 ,10, 20 etc).

I don't know how to change the referer to reflect '?offset=...' if it's there. I thought of using a wildcard but I don't know how to use them.

Can you help me out?
Question by:Pantyboy
    1 Comment
    LVL 18

    Accepted Solution

    You probably want to use a regular expression.  I'm on my way out the door, so this is a quick hack of one.  Someone else can probably provide a better working example that will meet all the instances you want:

    dim re
    set re = new RegExp
    re.IgnoreCase = true
    re.Global = false
    re.Pattern = "^.*20yearsTrustMessages.asp(\?offset=.*)?$"
    if re.test(Request.ServerVariables("HTTP_REFERRER")) then
    'do whatever here
    end if

    Open in new window


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
    I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now