What page sent 'em to 404.php?
Moderator: General Moderators
- vinyl-junkie
- Forum Newbie
- Posts: 23
- Joined: Sat Nov 22, 2003 2:52 pm
- Location: Seattle, WA area (USA)
What page sent 'em to 404.php?
I've searched LOTS of places, including here, and haven't found what I'm looking for. The saga continues of my conversion from ASP to PHP, with this question. On my custom 404 page in ASP, I have something like "the page you were trying to access - http://www.somepage.com - was not found or is no longer here." and so forth. In PHP, how do I do the same thing - capture what sent them to my 404 page? HTTP_REFERER doesn't work for that purpose, so what does?
you can use either of those in the $_SERVER global.
Example:
Example:
Code: Select all
$_SERVERї'PHP_SELF']
$_SERVERї'REQUEST_URI']- vinyl-junkie
- Forum Newbie
- Posts: 23
- Joined: Sat Nov 22, 2003 2:52 pm
- Location: Seattle, WA area (USA)
- vinyl-junkie
- Forum Newbie
- Posts: 23
- Joined: Sat Nov 22, 2003 2:52 pm
- Location: Seattle, WA area (USA)
At the risk of being picky, doing a .htaccess file only works on a Unix system. If you have a website that's on a Windows server, you can still have a custom 404 error page, but your web host will probably have to set that up for you.vigge89 wrote:Create a file with the following content:
ErrorDocument 404 /404.php
Name it as .htaccess
sorry if i am hijacking this post but i also tried useing
but it didt work at all, i am runing XP with Apache/1.3.27 (Win32) PHP/4.3.3RC1
. so maybe the above code doest work? 
Code: Select all
ErrorDocument 404 /404.php- vinyl-junkie
- Forum Newbie
- Posts: 23
- Joined: Sat Nov 22, 2003 2:52 pm
- Location: Seattle, WA area (USA)
No problem with the hijacking. This is an important topic after all.qads wrote:sorry if i am hijacking this post but i also tried useingbut it didt work at all, i am runing XP with Apache/1.3.27 (Win32) PHP/4.3.3RC1Code: Select all
ErrorDocument 404 /404.php. so maybe the above code doest work?
The above code should work, provided you have your 404 page named 404.php, and it is in your root directory.
- vinyl-junkie
- Forum Newbie
- Posts: 23
- Joined: Sat Nov 22, 2003 2:52 pm
- Location: Seattle, WA area (USA)
404.php is a web page, just like any other on your website. Just set it up with whatever message you want and visitors will get automatically redirected to it if you have a page that moved, they hand-type an incorrect URL, or whatever. Go here to see how mine looks on my Windows hosted site:volka wrote:and again...
vinyl-junkie: How and where did you set up your 404.php page?
http://www.napathon.net/xx.asp
Notice the part that shows you how you ended up there. Somehow, there's gotta be a way of doing the same thing in PHP.
Still no joy. One of these didn't return any value at all. The other still returned /404.php as the URL. *sigh*Both, $_SERVER['REDIRECT_URL'] and $_SERVER['REQUEST_URI'], should give you the actually requested url.
Oops. Sorry for misreading your inquery. 
Check out: http://httpd.apache.org/docs-2.0/custom-error.html
It might have some details that can help you.
Check out: http://httpd.apache.org/docs-2.0/custom-error.html
It might have some details that can help you.
Apache will define REDIRECT_URL and REDIRECT_STATUS to help the script trace its origin. Both the original URL and the URL being redirected to can be logged in the access log.