Click to See Complete Forum and Search --> : Clean URL / Semantic Web Question about Incoming requests (Web Dev Newbie)


goatslayer
September 8th, 2010, 03:31 PM
Hi,

To give some context, I'm more of a newbie to putting a single modern web system together than any one technology. I have a question about incoming requests and returning the correct representation.

Problem:

1. User accesses information about an item through "http://example.com/doc/item/313" - For arguments sake, this is a shop item with unique id 313

2. "http://example.com/doc/item/313" (html) - doesn't exist on the server, it needs to be dynamically generated.

What step am I missing / do I need to do for the server to recognise this request, then run a php script that then returns the correct representation. In this case html, however if the user specifies .rdf or .json for example recognise that and allow the php script to make a call to return that representation.

I hope that makes sense! - any help appreciated.

Ross

PeejAvery
September 8th, 2010, 06:13 PM
Sorry...but I'm confused. Are you talking about mod_rewriting (http://www.google.com/search?source=ig&hl=en&rlz=&q=mod_rewrite&aq=f&aqi=g10&aql=&oq=&gs_rfai=Ctb2ukxiITNa0EqmsoASrq8msBgAAAKoEBU_QJmly)?

goatslayer
September 8th, 2010, 06:34 PM
I suppose it doesn't help but I'm probably a little confused, I know what I want to achieve but don't quite know what it is called. Mod rewriting looks close but I'm not sure.

I need a clean URL basically that doesn't display any clue of it's implementation that when accessed by a browser can return the correct representation for the request. So from a standard browser:

http://www.example.com/doc/item/313

Will return a HTML file generated dynamically from a PHP script.

Now I know if i just wanted something like /index.php - I could do that, I just don't know what is needed to do that dynamically and using the redirect which means the .html / .php / .whatever isn't displayed.

So I think I need a redirect or something... so /doc/item/313 maps elsewhere.

Perhaps to a php controller function that can determine the representation and return it thus.

Is there a common name or design pattern that effectively explains this technique and how to achieve it?

PeejAvery
September 8th, 2010, 10:37 PM
Yes. It's called URL rewriting. It's done with mod_rewrite as I've already said. There are plenty of examples in the Google search I linked to.