php - How do I create permalinks that are database driven?
I'm looking for a way to translate
I'm ok with doing some sort of RewriteRule with Mod Rewrite, but I'm not sure how to do it exactly. My pages are coded in PHP pulling from a MySQL database.
Hopefully someone can tell me how to do this!
I know there are others looking for a similar answer.
You're going to need a rewrite rule in your web server configuration to translate e.g.
/index.php?id=123- it's not a PHP issue per se.
All the below stuff can be implemented with apache rewrites. You can find a ton of tutorials and documentation on how to do this.
In order to make permalinks look nice and SEO friendly, you can follow the pattern example.com/article/how-to-do-stuff as a link for the article entitled "How to do stuff". However if your site will get many articles, things will slow down a little bit because of text search in the database (that will be a hard to achieve level, but let's talk hypothetical).
As a result I'd recommend using the phpBB pattern example.com/article/12345-how-to-do-stuff where 12345 is the id of the pattern in the database (or any other id that's fast enough to select from db). That's not all. There 'should' be one more verification step, where the text from the URL, is compared with the title of selected article, and an eventual redirect to the correct URL will be done.