Guys,
Goodnight.
Today I will show you how to redirect your applications in case of a URL typing error, for example, where normally the Apache web server displays an error message and the visitor may have difficulty returning to your website. If he found your site through a search engine (aka Google), he will probably leave your site and return to Google. We can't let that happen, right?
Once again, I will turn to our great ally, the Apache HTTP Server configuration file, .htaccess to help us.
To create the redirect, we will use the directive ErrorDocument, as we can see in the example below:
## Redirecionar em caso de erros ##
ErrorDocument 400 /apache.php?erro=400
ErrorDocument 403 /apache.php?erro=403
ErrorDocument 404 /apache.php?erro=404
ErrorDocument 500 /apache.php?erro=500
ErrorDocument 501 /apache.php?erro=501
ErrorDocument 502 /apache.php?erro=502
ErrorDocument 503 /apache.php?erro=503
ErrorDocument 504 /apache.php?erro=504
ErrorDocument 505 /apache.php?erro=505
This will mean that for each HTTP error code, you have control over how you want to handle it. When the user types an invalid or non-existent URL (Error 404 – Not Found), I am redirecting to the URL /apache.php?error=404. Within the apache.php file, I carry out the necessary treatments, customization and visual art so that the visitor reads a friendly message informing them that the page does not exist and suggesting other URLs, using the layout of my website and several links available for them to navigate normally.
This way, we even win over visitors coming from broken links or mistakes! Oh, need help identifying HTTP error codes? Find out more by clicking here.
Until next time.
Comentários (0)
Carregando comentários…