Custom 404 error issues with Apache - the ErrorDocument is 404 as well

后端 未结 4 618
自闭症患者
自闭症患者 2020-12-03 04:51

I am trying to create a custom 404 error for my website. I am testing this out using XAMPP on Windows.

My directory structure is as follows:

error\\4         


        
4条回答
  •  悲哀的现实
    2020-12-03 05:14

    Instead of adding them to your .htaccess file, you can add them to any of your virtual host files.

    
    
        DocumentRoot /var/www/mywebsite
    
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
    
        ErrorDocument 404 /error-pages/404.html
        ErrorDocument 500 /error-pages/500.html
        ErrorDocument 503 /error-pages/503.html
        ErrorDocument 504 /error-pages/504.html
    
    
    

    Where error-pages is a subfolder in the mywebsite folder, containing the custom error pages. Make sure you restart your apache to view your changes.

    $sudo /etc/init.d/apache2 reload
    

提交回复
热议问题