1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Page level script based alternative to ISAPI filters?

Discussion in 'C#' started by Arizona Web Design, Feb 19, 2006.

  1. #1
    I was wondering if it was possible to get the same affect as an ISAPI filter to canonicalize URLs on the page level...
    SEMrush
    For example, if I want all my links to point to http://www.nextstudent.com/ but I have some without the www, some without the trailing slash, some to the .com/default.asp, and to the secure site, etc etc... could I run a script like this?

    
    '(in pseudo code)
    If [exact url displayed] is not equal to "http://www.nextstudent.com/" 
    Then
    301 redirect to http://www.nextstudent.com/
    End If
    
    Code (markup):
    Will that work if I place the script on the very top of the page?
     
    Arizona Web Design, Feb 19, 2006 IP
    SEMrush
  2. vectorgraphx

    vectorgraphx Guest

    Messages:
    545
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #2
    try this

    
    <%if Request.ServerVariables("SERVER_NAME") <> "www.nextstudent.com" then
    
    Response.Status="301 Moved Permanently" 
    Response.AddHeader "Location", "http://www.nextstudent.com/"
    
    end if%>
    
    Code (markup):
    HTH :D
     
    vectorgraphx, Feb 20, 2006 IP