--- On Fri, 10/17/08, Pete <[EMAIL PROTECTED]> wrote: > I have a database, with, say, articles, with ID, title, and > text. I just want to make the URLs of the pages become > sitename.com/title instead of the more usual > sitename.com/article.php?id=(ID from database). > > However, I don't want to manually add a line to htaccess for > each page / database entry, and I am nervous about making > programatic changes to htaccess (not even sure it it's possible) > because of the damage that it can do to the entire site. > > What I have done before, is to give the page a tail, like > .info, then get htaccess to rewrite the URL to > /article.php?title=(title from database). The tail allows > htaccess to recognise that this is an article. > > But is there a way to do this, just using /title as the url? > > -- > Pete Clark
One way to approach this would be to have an ErrorDocument 404 statement in your .htaccess which points to a PHP script. This will catch any URLs which don't exist on your system. The script can look at the requested URI ($_SERVER['REQUEST_URI']) and see if it matches (or is similar to) a page you have and want to display. If it is, the script can return that content. If not, display a helpful error message. It's up to you to scrub the URL to make sure that SQL injection and other nastiness is not possible when you search your database for appropriate content. James