There is a website that I designed as a standard, static website with pages that I update as required. All pages are *.html and I have some quite good google rankings.
I'm currently re-writing this site to add a CMS at the backend, this will either change all of the pages to end *.php or to use routes (which is more likely).
How can I change the site but keep existing links and search results?
e.g. If I have a link to www.mySite.com/myPage.h开发者_JAVA百科tml
, but in the future this will be www.mySite.com/myPage
how do I do this without breaking all links to myPage.html?
My hosting is LAMP at the moment, could this be done by altering the .htaccess file?
mod_rewrite should do the job. You just put something like this in your .htaccess
file
RewriteEngine on
RewriteBase /
RewriteRule ^(.*)\.html$ $1 [L,R=permanent]
This will cause all requests to www.example.com/yourpage.html
to be rewritten to www.example.com/yourpage
. The R=permanent
part causes a permanent redirect reply to be sent to the client, which should cause well-behaved search engines to update their entries.
精彩评论