DEV Community

popoola Temitope
popoola Temitope

Posted on

404 page redirecting using .htaccess

Using .htaccess to redirect user to 404 page when ever an invalid url is enter.

To do this is very simple Follow the steps below.

  • On the file manager open Public_html folder.
  • locate .htaccess file and open it for editing


  • add this code to the htaccess file code (add at the bottom of the code)

  • 
    ErrorDocument 404 /404.php
    
    
    Enter fullscreen mode Exit fullscreen mode

    The code should look like this

    
    # HTID:15003771: DO NOT REMOVE OR MODIFY THIS LINE AND THE LINES BELOW
    php_value display_errors 1
    # DO NOT REMOVE OR MODIFY THIS LINE AND THE LINES ABOVE HTID:15003771:
    ErrorDocument 404 /404.php
    
    
    Enter fullscreen mode Exit fullscreen mode

    Note: to add redirect to 404 page on each folder, you have to add .htaccess to each folder.

    Top comments (0)