View Full Version : 500+ html pages.. converting to dynamic.. need to keep URLs.

09-08-2011, 03:08 AM

A friend of mine has asked for help to convert his site to a dynamic website. It has 500+ static html pages which he would like converted to PHP so that the site can run from one template, add/edit/delete articles quickly and generally be more efficient.

The problem is that the site is listed highly in search engines for certain terms with the static URLs EG http://www.his-site.com/sites/site215.html. Obviously converting to a dynamic system will loose this and affect his search engine ranking considerably.

I can convert the site to php with minimal fuss however we need to preserve these URLs. I have several ideas but I'm not clued up in this area so need some advice:

1) Issue 302 errors for all of the urls pointing to the new urls article.php?id=215
2) Mod rewrite? - I've no idea how to use it in this scenario.
3) Leave all the html files there with redirects and meta tags.

Any chance of some advice here? - This is a large professional site and while PHP/MySQL isn't a problem I can't let the guy down and need a rock solid solution.

Many thanks,


09-08-2011, 08:29 AM
Yes, mod_rewrite is the answer. The site215 part is assumably somekind of unique identifier that you have added as a database field, if it's not, then it needs to be (if they are all site, you can obviously just keep the 215 part). Then you use something like this...

RewriteCond %{REQUEST_URI} !-f
RewriteRule ^sites/site([0-9]+)\.html$ /article.php?id=$1 [L]

NB. Bare in mind you need to change any links on your page to be sites/site215.html, rather than article.php?id=215, this is not automatic.