404 page not found not working with my .htaccess

I have a lower .htaccess on a server with rules for pages not found, but it does not work. Any idea?

RewriteEngine on RewriteRule ^article_detail/([a-zA-Z0-9_-]+)/([0-9]+)\.html$ article_detail.php?article_det=$2 Options +FollowSymLinks ErrorDocument 404 http://www.example.com/main/404_not_found.html # compress text, HTML, JavaScript, CSS, and XML <IfModule mod_ext_filter.c> AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE text/xml AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE application/xml AddOutputFilterByType DEFLATE application/xhtml+xml AddOutputFilterByType DEFLATE application/rss+xml AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE application/x-javascript # remove browser bugs BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4\.0[678] no-gzip BrowserMatch \bMSIE !no-gzip !gzip-only-text/html </IfModule> 
+4
source share
6 answers

I assume that you are using Apache and not IIS;

  • Make sure you turn on the modem overwrite feature . You can do this by specifying the line below in the httpd.conf file (usually in the /conf/ directory. This could be different if you are using shared hosting and removing the half-density from the beginning of the line)

    ;LoadModule rewrite_module modules/mod_rewrite.so

  • Find the appropriate directory tag for your www root and change AllowOverride None to AllowOverride All

  • Create a .htaccess file in the root directory (if it does not exist)

  • You will need to insert something similar to this ;

    ErrorDocument 500 /errordocs/500.html

    ErrorDocument 404 /errordocs/404.html

    ErrorDocument 401 /errordocs/401.html

    ErrorDocument 403 /errordocs/403.html

    • Instead of ErrorDocument 404 /errordocs/404.html you can also make ErrorDocument 404 http://www.yourdomain.com/errordocs/404.html or even just display the simple ErrorDocument 404 "Sorry can't allow you access today" message ErrorDocument 404 "Sorry can't allow you access today"

    • If you are having problems, the Apache Handbook (ErrorDocument directive) should help you further.

In your case, make sure that AllowOverride All enabled, editing the .htaccess file in the root directory and make sure that you can click the URL of the error page if the URL you provided does not indicate that Apache will return 404 by default .

+19
source

In your apache configuration, under the Directory section of your website, make sure that you are allowed to override the FileInfo directive.

Somthing like

AllowOverride FileInfo

http://httpd.apache.org/docs/current/mod/core.html#errordocument

+1
source

Try disabling the line from httpd.conf in the apache configuration.

 #LoadModule rewrite_module modules/mod_rewrite.so 

uncommented:

 LoadModule rewrite_module modules/mod_rewrite.so 

Also restart apache

+1
source

Have you tried ErrorDocument 404 /main/404_not_found.html ?

Just do you have something stopping your url (not sure if this is your full htaccess)? I usually donโ€™t put the whole URL, although technically you can.

Also can you access page 404 directly?

0
source

Try changing the line with ErrorDocument 404 http://www.google.com

If this works, it means that the path you used was wrong. I do not know your directory structure, so I can give you good code for writing.

I don't think this is a .htaccess error, because you will get an internal 500 error, if any.

If these tricks do not work, it means that you are redirected inside your apache configuration.

0
source

Why is this ... I have an html5 404 page ... and when I just add a local path, it does not look right.

0
source

Source: https://habr.com/ru/post/1491315/


All Articles