Page 1 of 1
Pretty Urls
Posted: Fri Nov 26, 2010 9:41 am
by evans123
How would i go about creating a pretty url script? Ive looked on the net for some example code and can't seem to find much.
Re: Pretty Urls
Posted: Fri Nov 26, 2010 10:25 am
by Zyxist
The first thing you need is mod_rewrite or similar server extension that would allow you to avoid file names in the URL address. The second thing is a router. It's a component that performs a translation:
* URL address -> request argument list
* argument list -> URL address
Routers usually contain some URL patterns, so that they know which pieces of the address should be mapped to what arguments.
Re: Pretty Urls
Posted: Fri Dec 10, 2010 8:26 am
by evans123
I have created my permalink script/structure now.
/Directory/Category/Sub Category/
When trying to edit say individual users should i use a permalink like /members/edit/username or use the old fashioned way of $_GET from the url?
Re: Pretty Urls
Posted: Fri Dec 10, 2010 12:26 pm
by Jonah Bron
What do you mean "old fashioned"? That's how you get data from the url rewrite.
http://www.google.com/search?q=mod_rewrite+tutorial
Re: Pretty Urls
Posted: Fri Dec 10, 2010 3:17 pm
by evans123
Yeah but would it be better to use /edit/username or ?edit=username, for example.
Re: Pretty Urls
Posted: Fri Dec 10, 2010 4:12 pm
by Jonah Bron
Yeah. That's what url rewriting is
for. It takes a URL like this (for example):
http://example.com/edit/joe
And maps it to (say) this:
http://example.com/edit.php?username=joe