I’ve got a PHP file called books.php, and I’d like to use SEO URLs using htaccess and PHP.
I would like to create rules for the following formats:
books.php?bookid=X (Optional: books.php?bookid=X&page=Y)
books.php?categoryid=X (Optional: books.php?categoryid=X&page=Y)
books.php?do=search&query=X
books.php?do=search&tag=X
These would be accessible through:
/books/book/{booktitle}
/books/category/{categorytitle}
/books/search/{search_string}
/books/tags/{tagtext}
What I’d like to know is the main idea for doing this.
Thanks!
I find it’s easier to just do something like this:
Where the number is the database ID, and the plain-text title is just thrown away by the PHP. It’s not as clean, but there’s too many problems involving uniqueness if you try to pass the title in to a SQL query IMO.
Check out the mod-rewrite generator here for help building rules.