apache - Redirecting multiple old pages to new pages -
apache - Redirecting multiple old pages to new pages -
i'm changing construction of pages , need re-direct old ones new pages.
here illustration of of next pages need move, in pages
folder needs moved down, old pages showed php
extension.
www.example.com/pages/index.php www.example.com/index www.example.com/pages/contact_us.php www.example.com/contact_us
here have far
options +followsymlinks -multiviews rewriteengine on rewriterule ^pages/(.*)$ /$1 [l,r=301]
edit
the rewrite above works makes pages such example.com/contact_us unusable, have set extension .php @ end, not problem had prior rule
you can utilize code in document_root/.htaccess
file:
rewriteengine on rewritebase / rewritecond %{the_request} \s/+pages/(.+?)\.php[\s?] [nc] rewriterule ^ /%1 [r=302,l,ne] rewritecond %{request_filename} !-d rewritecond %{document_root}/pages/$1\.php -f [nc] rewriterule ^(.+?)/?$ pages/$1.php [l]
apache .htaccess mod-rewrite
Comments
Post a Comment