php - .htaccess Internal Server Error: ErrorDocument not working (RewriteEngine on) -
whenever have rewriteengine on errordocument - part not working. current .htacces file:
errordocument 404 404.php options -multiviews rewriteengine on rewritebase / rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ /$1.php [qsa,l]
so when open not existing file in browser, 500 internal server error , not getting redirected 404.php - file.
please me ;)
this because you're blindly rewriting .php
end of uri. let's take see happens when go 404 url:
- you request:
http://example.com/blahblah
- the uri not file (passes
!-f
) - the uri not directory (passes
!-d
) - the uri matches
(.*)
. - the uri gets rewritten include
.php
- the uri
/blahblah.php
- the uri not file (passes
!-f
) - the uri not directory (passes
!-d
) - the uri matches
(.*)
. - the uri gets rewritten include
.php
- the uri
/blahblah.php.php
- the uri not file (passes
!-f
) - the uri not directory (passes
!-d
) - the uri matches
(.*)
. - the uri gets rewritten include
.php
- the uri
/blahblah.php.php.php
etc.
you need make sure you're rewriting exists or cause loop:
rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewritecond %{document_root}%{request_uri}.php -f rewriterule ^(.*)$ /$1.php [qsa,l]
Comments
Post a Comment