Problem with dynamic 404 error page in php on iis

Posted on 2004-11-24
Last Modified: 2012-06-21
I am running IIS 5 with php

I want a dynamically generated 404 error page

I definded my 404error.php  page in the custom errors section of my website settings

when i run the page the file is returned but the php scripts do not run. In fact they actually show up as body copy

does any one have any advice?

Question by:mediatimebomb
    LVL 3

    Expert Comment

    First, does php run at all? (Create a new file with <?php phpinfo(); ?> in it, and make sure it gets run.)

    LVL 2

    Expert Comment

    Have you tried defining a normal html page as the error page and putting a simple redirect to the php page on the html page?

    Author Comment

    yes php runs and i would rather avoid yet another redirect expecially off the 404 page.

    i need to read some variable e.g. what page was called right on the 404 if i pass it in a simple ridirect i cannot do this
    LVL 3

    Expert Comment

    Well, you could

    Page 404.html

    window.location = "404.php"

    Page 404.php
    $thepage = $_SERVER['HTTP_REFERER'];
    404 page not found, you request page <?php echo($page); ?> and it was not found.. please check the URL and try again, blah blah blah

    Because if I remember correctly, the 404 page is not redirected, rather the page requested is re-written with the contents of the 404 page. Thus the referer is still going to be the page requested.


    Author Comment

    I do appreciate the above suggestions but they are not the solution i need for this to work. I do now want to run sripts on this page the purpose of me wanting to run php on the 404 page is to get a dynamic site map on there will links that SEO spiders can crawl. Having a javascript redirect will put a stop to that


    Accepted Solution

    PAQed with points refunded (250)

    Community Support Moderator

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    A colleague recently asked me about how to give his client a small part of the web site that could be completely under the client's control.  Since I have done this sort of thing before to add emergency banners to a web site, I decided I would creat…
    These days socially coordinated efforts have turned into a critical requirement for enterprises.
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    754 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

    19 Experts available now in Live!

    Get 1:1 Help Now