Get Page URL For 404
Is there a way to get the URL for a page that gave a 404 error? I'm trying to make a 404 page that searches the url for words which i can use to redirect them to a more appropriate page (pretty easy considering the category and product names are in the url). I've been able to get the referrer, but having the actual url itself that threw the 404 is what i need.
Anyone have any ideas?
Sure - depending on your web server software you can set the default 404 page, and direct all 404s to a PHP script that can parse the URL and send people where you want them to.
I would suggest adding an .htaccess file with the following (or adding this to your existing one):
and then creating a redirect.php that parses the URL (perhaps using $_SERVER['SCRIPT_NAME']) and redirects the user to the appropriate location.
ErrorDocument 404 /redirect.php
Originally Posted by Jarrod1937
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)