Pretty Urls
Moderator: General Moderators
Pretty Urls
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
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.
* 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
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?
/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?
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: Pretty Urls
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
http://www.google.com/search?q=mod_rewrite+tutorial
Re: Pretty Urls
Yeah but would it be better to use /edit/username or ?edit=username, for example.
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: Pretty Urls
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
http://example.com/edit/joe
And maps it to (say) this:
http://example.com/edit.php?username=joe