I am using .htaccess to get the Referrer URL. For example, if someone clicks the link example.com/dogfood-post-1 and the post is not found, how can I get that URL example.com/dogfood-post-1 in my 404.php page?
ErrorDocument 404 /404.php
I am using .htaccess to get the Referrer URL. For example, if someone clicks the link example.com/dogfood-post-1 and the post is not found, how can I get that URL example.com/dogfood-post-1 in my 404.php page?
ErrorDocument 404 /404.php
Not really a full answer as it depends on specific configuration, but this should help you.
Add var_export($_SERVER)
to your 404.php and see which key contains the value you need.
If you just want the url on the domain.com/dogfood-post-1 you could use:
$actual_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
source: get full url stackoverflow
if you send them to another page you could set a session and put the url in the session and then display it on the 404 page.
Instead of redirecting users to a 404 page you should show them the 404 error page. In your .htaccess you can add:
ErrorDocument 404 /appName/404.php
Put your absolute path before the 404.php in order to show it properly.