How to Force Apache To Show a HTTP-410 Gone Status Code

To force Apache to show a HTTP-410 Gone status code, you need to add a custom error response in your Apache configuration file. Here’s how to do it:

  1. Open the Apache configuration file, usually located at “/etc/httpd/conf/httpd.conf” or “/etc/apache2/httpd.conf”, using a text editor as root or using sudo.
  2. Add the following line inside the VirtualHost section that corresponds to the website you want to configure:
ErrorDocument 410 /path/to/410.html

This line specifies the 410 status code and the file that should be displayed as the response. Replace “/path/to/410.html” with the actual path to your 410 response file.

  1. Create the 410 response file at the location specified in the ErrorDocument directive. You can add any content you want to display to the user, such as a message explaining why the page is no longer available.
  2. Restart Apache for the changes to take effect. You can do this by running the following command as root or using sudo:
systemctl restart httpd
  1. Test the configuration by accessing a URL that should return the 410 status code. You can verify the status code by using a tool like curl or by checking the HTTP headers using a browser developer tool.

Note: The steps above are for Apache on a Linux system using systemd. If you’re using a different operating system or service manager, the commands to restart Apache may be different.

Leave a Comment