Reputation: 39
I want to redirect my users to
www.spredt.com/404
But still having the url look the same as they typed it in the first place.
For example is someone entered www.spredt.com/93817218
and that page
doesn't exist in my directory it will redirect them but it will change
the url to www.spredt.com/404
I want the same /93817218
to stay unchanged in the url but still redirect them to the error document 404.
Right now I'm handling redirection with the .htaccess
file.
ErrorDocument 500 https://www.spredt.com/500
ErrorDocument 404 https://www.spredt.com/404
ErrorDocument 403 https://www.spredt.com/403
But this changes the url.
Upvotes: 1
Views: 2039
Reputation: 382
I presume that you are redirecting your user in the 404 endpoint. But you can just return the 404 page template when they enter a false url, and not redirect them. The url will stay the same and they will see your 404 page.
I can't provide more detail because I don't have your code nor the langage.
EDIT :
In PHP you can do that to redirect and stay on the same URL :
include('http://www.spredt.com/404');
exit();
I can't test it right now, but it should work.
Source : https://bytes.com/topic/php/answers/545026-redirect-without-changing-address-your-browser
Upvotes: 2