canadabeeau Posted December 1, 2009 Share Posted December 1, 2009 Hi I want my error 403 pages to also say which URL the user tried to visit, ie <?php echo "You can not visit:".$pagetriedtoview.", sorry if this is not okay.";?> How can I do this? Quote Link to comment https://forums.phpfreaks.com/topic/183557-error-page/ Share on other sites More sharing options...
Daniel0 Posted December 1, 2009 Share Posted December 1, 2009 You can use REQUEST_URI. <?php header('HTTP/1.1 403 Forbidden'); echo 'You cannot access this page: ' . filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_SPECIAL_CHARS); Note that sending the proper response code is actually important. Quote Link to comment https://forums.phpfreaks.com/topic/183557-error-page/#findComment-968836 Share on other sites More sharing options...
canadabeeau Posted December 1, 2009 Author Share Posted December 1, 2009 REQUEST_URI will display the current URI not the one that the 403 is occuring becuase of Quote Link to comment https://forums.phpfreaks.com/topic/183557-error-page/#findComment-968856 Share on other sites More sharing options...
Daniel0 Posted December 1, 2009 Share Posted December 1, 2009 How are you displaying it? If you view http://www.phpfreaks.com/forums/foo/bar/doesnt-exist.html?test=hello you'll see that REQUEST_URI specifically will be the page the user tried to exist (except this is Apache's default 404 error page, not a custom 403 error page). Quote Link to comment https://forums.phpfreaks.com/topic/183557-error-page/#findComment-968934 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.