Forum Moderators: phranque

Message Too Old, No Replies

Creating Static URLs with .htaccess and MySQL

Create SEO URL MySQL

         

plethera21

5:25 pm on Dec 29, 2006 (gmt 0)

10+ Year Member



I've got a website that has several hundred php pages. Currently I create a new entry in a mySQL table and use a php "template" page to create the various pages on my website. For each page I create, I just change the mySQL ID, and everything is then changed on the page like the title, description, ect.

Since my website is growing, I'm looking for a way to automatically create SEO friendly URLs by just typing in the URL and having the .htaccess file search the mySQL database for the title of the page, and then display that page with a static URL. So if the title of my article was "Somewhere in time", I would type in: www.mysite.com/somewhere-in-time.php and the .htaccess file would find that title and direct the user to that page. Any help would be greatly appreciated!

jdMorgan

6:02 pm on Dec 29, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you have server configuration file access, you can create a RewriteMap to pass such requests to a cgi script that does the database lookup and returns the proper filepath and/or query string to mod_rewrite in either the server config files or in per-directory .htaccess files.

To be clear: The RewriteMap must be defined in httpd.conf or conf.d, but can then be invoked from httpd.conf, conf.d, or from .htaccess.

Jim