creating a uri or url?

im not sure if ive worded my question correct.

but im building a webservice about books but im not sure how i can get the isbn into the url like how my lecturer has done it eg.

http://creative.coventry.ac.uk/~bookshop/v1.1/index.php/book/isbn/1283982392380238

so where the numbers are. This is part of a put method for adding a book to the database.

im going to use something similar for users but im not sure how to put the isbn that the user submits into the uri?

In an Apache-environment you could use the module mod-rewrite to rewrite (d’uh) the url to your liking

this url:
yoursite.com/index.php/book/isbn/1283982392380238 (1)

could be rewritten to
yoursite.com/index.php?module=book&isbn=1283982392380238 (2)

This means that a user who visits the #1 url will be silently served the #2 url. You can then use the isbn number in your php application using $_GET[‘isbn’]

You can create simple rewrites here:
http://www.generateit.net/mod-rewrite/index.php

Example at the mod rewrite generator

http://yoursite.com/index.php?module=book&isbn=1283982392380238

parameters
module: value
isbn: name and value

prefix (not needed really, but just to get it exactly like your example pretty url)
index.php/

suffix
none

results in:
http://yoursite.com/index.php/book/isbn/1283982392380238

[hr]

You should add this code to a .htaccess file in the folder you have the script in

RewriteEngine On RewriteRule ^index\.php/([^/]*)/isbn/([^/]*)$ /index.php?module=$1&isbn=$2 [L]

if you need to be able to send more get variables you must add QSA (attach query string) in addition to the L

RewriteEngine On RewriteRule ^index\.php/([^/]*)/isbn/([^/]*)$ /index.php?module=$1&isbn=$2 [L,QSA]

Sponsor our Newsletter | Privacy Policy | Terms of Service