apache - Remove trailing .html rewriterule creates 404 error -
i have modified .htaccess remove trailing .html pages. htaccess looks this:
rewriteengine on rewritebase / rewritecond %{http://www.mydomain.co.uk} !(\.[^./]+)$ rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule (.*) /$1.html [l] rewritecond %{the_request} ^[a-z]{3,9}\ /([^.]+)\.html\ http rewriterule ^([^.]+)\.html$ http://www.mydomain.co.uk/$1 [r=301,l]
i added following @ top of .htaccess set custom 404 page , stop indexing:
errordocument 404 /notfound.html options -indexes
the rewrite rule works perfectly. anti-indexing. 404 page gives me error:
internal server error server encountered internal error or misconfiguration , unable complete request. please contact server administrator, webmaster@mydomain.co.uk , inform them of time error occurred, , might have done may have caused error. more information error may available in server error log. additionally, 500 internal server error error encountered while trying use errordocument handle request.
if remove rewriterule 404 page works fine. don't know lot kind of stuff , wondering able both aspects work correctly? can please?
(ps: read this answer , think might apply me - didn't understand @ all.)
just wanted let know found solution this:
errordocument 404 /notfound.html options -indexes rewriteengine on rewritebase / rewritecond %{the_request} ^[a-z]+\ /([^/\ ]+/)*[^.\ ]+\.htm\ http/ rewritecond %{request_filename} -f rewriterule ^(([^/]+/)*[^.]+)\.htm$ http://www.example.com/$1 [r=301,l] rewritecond %{request_filename} !-d rewriterule ^(.+)/$ http://www.example.com/$1 [r=301,l] rewritecond %{request_filename}.html -f rewriterule ^(([^/]+/)*[^./]+)$ /$1.html [l]
works great!
Comments
Post a Comment