I don't think you understand. This doesn't work as a redirect. The URL they requested stays in the browser's URL bar. Also, you can use getenv("HTTP_REQUEST") to see what page they tried to get to.

    Technically it's not a redirect, no, the webserver just calls the 404 file when it fails to find the requested file.

      No, I've used both forms of 404 catching by .htaccess. The one I showed just displays the code. The other way actually sends you to another page, changing the URL in the browser. Is he using something other than .htaccess to catch 404 errors?

        Sends you to another page? What did you do? The method for creating a 404 page is usually done like so:

        ErrorDocument 404 /404_page.php

        If you added the full path, i.e. http://mydomain.com/404_page.php then yes, Apache will see that as a redirect instead of an internal redirect.

          Oh, ok. But couldn't you still use getenv("HTTP_REQUEST") to see what page they tried to find?

            I don't see any server variable called HTTP_REQUEST... only one called REQUEST_URI.

              I could have sworn there was one... nevermind. I drained my mind earlier today, there's none left. Please continue your conversation without my interruptions.

                Hi,
                Thanks for your valuable help. I was informed very well due to your replies.
                I found another approach to get the URL of the missing page. It is the client side approach. i.e JavaScript.
                Using [FONT=Lucida Console]document.location[/FONT], will give the location of the page, since, apache does not lead to change the missing page URL from the browser's address bar.
                A text file is attached named e404.txt show what I have done. To test it, please change its extension to .php

                  And what happens when the person has disabled Javascript? Or their browser doesn't like your JS coding? I tested this in Opera and FireFox, and saw this:

                  URL requested is: 

                  So, your code only works for IE users who have enabled Javascript.

                    You are right. JavaScript is not the most effective solution in this case.

                      I use PHP whenever possible. Javascript is only good when you have to do something after the page is loaded.

                        Write a Reply...