开发者

Change extension of webpage but keep search results

开发者 https://www.devze.com 2023-02-22 14:03 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消