apache - htaccess 404 Stopped Working -


i had custom 404 error redirect page working fine through htaccess. however, after adding new code htaccess, stopped working. what's causing conflict , how can fix it?

edit: i've tried putting errordocument line @ top of page , still doesn't work.

htaccess code:

rewriteengine on  #removes www rewritecond %{http_host} ^www\.(.+)$ [nc] rewriterule . http://%1%{request_uri} [r=301,l]  #redirects extensionless php urls rewritecond %{the_request} ^[a-z]{3,9}\ /([^&\ ]+).php rewriterule .* /%1? [r=301,l] rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^(.*)$ $1.php [l]  #redirect nonexistent files 404 page (not working) errordocument 404 /404.html 

the problem not putting errordocument in top or in bottom of htaccess.

you have infinite loop because of rule (the 1 rewriting php extension).
need check if exists before rewriting it, otherwise you'll loop conflict between rule , errordocument.

you can replace current code one

rewriteengine on  #remove www rewritecond %{http_host} ^www\.(.+)$ [nc] rewriterule ^ http://%1%{request_uri} [r=301,l]  #hide php extension (only existing files) rewritecond %{the_request} \s/(.+)\.php(?:\s|\?) [nc] rewritecond %{request_filename} -f rewriterule ^ /%1? [r=301,l]  #redirect extensionless php urls (only if exists) rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewritecond %{request_filename}\.php -f rewriterule ^(.*)$ /$1.php [l]  #redirect nonexistent files 404 page errordocument 404 /404.html 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -