When I try to access the below URL in my WordPress website on the NGINX server it's showing a 400 Bad Request error. I want to show a custom page whenever this error message occurs. For example, when I try to access the below URL it's showing 400 Bad Request nginx error page. Here is the URL I am entering to generate the error.


What will be the best solution for this?

1 Answer 1


To display a custom error page for 400 errors on an Nginx server, you can try and use a custom error page. This could be an HTML page with the content you want to show to users when they hit a 400 error.

Once you have created the custom error page, you will need to edit your Nginx configuration file. This is usually located at /etc/nginx/nginx.conf or /etc/nginx/sites-available/default or a similar location, depending on your server setup.

You would then add an error_page directive inside the server block for your site, pointing to the location of your custom error page. It would look something like this:

server {
    listen 80 default_server;
    server_name example.com;
    # Rest of your configuration...

    error_page 400 /path/to/your/error400.html;
    location = /path/to/your/error400.html {

In the above configuration, replace /path/to/your/error400.html with the actual path to your custom error page. You might need to restart your Nginix service to make these changes work.

  • Can I do it by modifying a .platform.app.yml file? I have added this code in my .platform.app.yml file as: errors: 400: redirect: /error/400.html
    – tek bhatt
    Commented Jun 20, 2023 at 11:36
  • I have put the above code in the web section of my .platform.app.yml file as: # The configuration of app when it is exposed to the web. web: locations: "/": # The public directory of the app, relative to its root. root: "wordpress" # Other Code # Other Code # Other Code # Other Code errors: 400: redirect: /terms-of-use
    – tek bhatt
    Commented Jun 20, 2023 at 11:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.