I have a website for a client, but when I go to www.example.com and insert special characters, let’s say www.example.com/$%#&, Nginx give me a 400 Bad Request error.
What I want here is, instead of that error, redirect the user automatically to the home page.
How can I do that?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
nano /etc/nginx/sites-available/default
Add
error_page code_number file_source;
e.g error_page 400 /;
service nginx restart
Thank you so much.
What I’m hosting is a web app, and its index y located in /web/app.php. So I put in Nginx:
error_page 400 /web/app.php;
It works perfectly, but now when the redirection happens, I can see the url www.example.com/web/app.php. How can I do to make it look just www.example.com?
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.