How do get 404 error pages to run scripts?

Discussion in 'Site & Server Administration' started by Arizona Web Design, Mar 8, 2006.

  1. #1
    In IIS I specified a different file than the standard one for my 404 errors- that part works fine. I think this is where I am messing up...

    At the top of my 404 page, I tried to plus in a script (in pseduo)
    
    if RequestedURL = X then
    301 redirct to Y
    end if
    
    Code (markup):
    The reason I am trying to do this is because somehow I got a very nice listing in DMOZ (which I already requested they change) that has anchor text for my main key phrase right there in the link... but they linked to mydomain.com/articles/ anchor-text-page

    There is a space between the path and the file name

    This means I can't just do a server based 301 redirect. There is no file to set it to redirect from because the space in the URL would mean I would have to start the file name to redirect from with a space, which windows automatically deletes...

    Any ideas? (aside from ISAPI filters) Is fixing the 404 page going to help?
     
    Arizona Web Design, Mar 8, 2006 IP
  2. chengfu

    chengfu Well-Known Member

    Messages:
    113
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    108
    #2
    Are you sure that dmoz has the link incorrectly and it's not only a glitch in the output? DMOZ should have a robot that checks for 404 errors on any linked pages and informs the editor.
     
    chengfu, Mar 8, 2006 IP
  3. Arizona Web Design

    Arizona Web Design Guest

    Messages:
    134
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I'm not sure, but either way the URL listed and the link have a space between the file name and the path. It's odd
     
    Arizona Web Design, Mar 8, 2006 IP
  4. TooHappy

    TooHappy Guest

    Messages:
    504
    Likes Received:
    39
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Try this:

    CameFrom = lcase(Request.ServerVariables("HTTP_REFERER"))

    If instr("dmoz.org/health/alternative/alexander_technique/", CameFrom) then Response.Redirect "correct_page.asp"

    (not tested)
     
    TooHappy, Mar 8, 2006 IP
    Arizona Web Design likes this.
  5. Arizona Web Design

    Arizona Web Design Guest

    Messages:
    134
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hi TooHappy,

    Thanks for taking time to help me out with the code snip, but I think the script is not the problem. The problem is that the server already returned a 404 to the client, and for some reason my 404 page can't run scripts even though it has an ASP extension. I don't quite understand the problem fully, but I think the answer lies in IIS configuration somewhere.
     
    Arizona Web Design, Mar 8, 2006 IP
  6. TooHappy

    TooHappy Guest

    Messages:
    504
    Likes Received:
    39
    Best Answers:
    0
    Trophy Points:
    0
    #6
    It should be able to run the .asp extension which tells me that you are pointing to a file and not a url in the IIS config? Correct?

    Try this:

    Go into IIS Manager, find your website, right click, choose properties, custom errors, click on 404 and select URL (not file) and then give it the name of your error traping page, say trapit.asp so (/trapip.asp).

    And if that doesn't work, you can always give http://www.helicontech.com/download/#isapi_rewrite a shot. That will solve any problem :)

    Hope that helps!
     
    TooHappy, Mar 8, 2006 IP