I am working on creating page links from DB like the following example.
Current page:
www.example.com/page.php?pid=7
In the DB it is saved as title “contact-us” under category “Company Info”
I want it to be like:
www.example.com/company-info/contact-us.html
I have tried different solution and answers but did not got any luck. I am not sure, where will be the PHP part and which rules to write for .htaccess files.
If you want to find this page by url, you will probably do this through php and .htaccess. Make a .htaccess that calls
page.phpfor each and every request. You don’t need thepid=7, because, well, how should the .htaccess know it is 7, right? 🙂In page.php, you take the original url and split it on the slashes, so you get the category (
company-info) and the page itself (contact-us.html). Then, you can look these up in the database. This is in a nutshell how many software works, including Wikipedia (MediaWiki) and CodeIgnitor.Mind that ‘company-info’ isn’t the same as ‘Company Info’. You’ll have to specify the url-version in the database to be able to use it for look-up.