regex - Apache2 - mod_rewrite and .htacess - Not working 404 rule when i add other rules -
here current .htaccess file:
rewriteengine on rewritecond %{the_request} ^[a-z]+\s([^\s]+)\.php\s rewriterule .* %1.html [r=301,l] rewriterule ^(.*)\.html$ $1.php errordocument 404 /page-404.html
like when open adress ending .php auto redirected same adress ending of .html want.
when remove these lines:
rewriteengine on errordocument 404 /page-404.html
and try open non-existing directory got 404 error redirected page want. problem comes when add additional lines shown in first code posted.
where problem , why 404 error redirection not working in first example ?
thanks in advance!
have rules this:
errordocument 404 /page-404.html rewriteengine on rewritecond %{the_request} ^[a-z]+\s([^\s]+)\.php\s [nc] rewriterule .* %1.html [r=301,l] # make sure .php file exists requested .html file rewritecond %{document_root}/$1\.php -f [nc] rewriterule ^(.+?)\.html$ $1.php [l,nc]
Comments
Post a Comment