View Single Post
Old 08-19-2012, 02:34 PM   #2 (permalink)
tony
The Addict
 
tony's Avatar
 
Join Date: Aug 2008
Posts: 336
Thanks: 8
tony is on a distinguished road
Default

There are tutorials about URL rewrite everywhere in the internet. But for completion purposes A quick example of how to do rewrite:

Code:
# Turn on URL rewriting
RewriteEngine On 

# Rewrite titles and IDs
RewriteRule ^books/([0-9]+)/(.*)/?$ books/page.php?id=$1 [L]
Don't forget to enable mod_rewrite in your apache configuration.
The gist of rewrites is if you know regular expressions, you know how to do it.

Here is a cheatsheet for Apache rewrite.

All this is assuming you use Apache for web hosting server.

P.S. I didn't test the rewrite rule, just came about using your criteria

About this part:

Quote:
Originally Posted by ramtindow View Post
witch then we should be able to use url "example.com/books/1/an-example/" instead of "example.com/books/page.php?id=1"
I don't know what you meant by this, you already have a valid id to query for a book in the database. I don't see why you need to ids (id and title).

I hope this helps.
tony is offline  
Reply With Quote