I have a 2 year old static HTML and CSS website. The site has over 150 pages and it’s too much work to keep it updated (like sidebar content, menu, head section or footer).
So now I want to convert my static HTML and CSS website to PHP (and use php includes), but because of SEO reasons (backlinks to my site) I want to keep the .html file extension.
Example:
www.example.com/malware.php becomes www.example.com/malware.html
Before I used Server Side Includes, but found out that SSI’s cause security problems like SSI injections (happened to me).
My website is hosted on A2 Hosting (TURBO shared hosting account) https://www.a2hosting.com/web-hosting/compare.
Which lines of code in the .htaccess file can do this?
3
Answers
Thanks everybody for your answers, but i just found the solution after searching for awhile. I've just included the following lines in the .htaccess file and it works.
Add this in your .htaccess file
There are two different ways to have Apache interpret
.html
as.php
and handle them as such.Normally, you’d use this:
But I’ve found for some shared hosting accounts, you need to adjust this command, and use the following.
Do bear in mind that this will increase the server load for your website, but unless you do something very stupid (which your host will protect against) you should be fine.
You can perform a 301 redirect as outlined in these other answers, and Google will certainly re-index your website fairly quickly. However there will be a couple of weeks of your website’s position in the search result fluctuating.