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

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -