Question about URL's

Mavix

Senior Member
Joined
Aug 14, 2006
Messages
759
Reaction score
3
Location
Durban
I've noticed a growing trend among websites (Facebook being the latest) to have some kind of URL that does not point to a specific file. For example you could have website.com/someCategory/someSubCategory/someProduct, or perhaps www.facebook.com/username.

I normally use PHP for web programming (Which Facebook uses as well last time I checked). Now my question is this: How does one go about using URL's in this format? Because I'm sure they not going to make a folder for each category/product/username! The only way I can think of is from the index page to parse the URL and to figure out from there what to do. Is that how it's done, or is there another way?
 
You should have a look at tutorials on SEO and also url rewriting, which allows you to match a url pattern such as myurl.com/(category name)/(product name), and have it redirect to a script which can parse the inputs.
 
You should have a look at tutorials on SEO and also url rewriting, which allows you to match a url pattern such as myurl.com/(category name)/(product name), and have it redirect to a script which can parse the inputs.

Thanks I'll have a look at those.
 
mod_rewrite

The most common method uses URL rewriting. The webserver sees the request for www.mysite.com/someuser and translates it to www.mysite.com/users/name=someuser?view=profile

So the PHP script just returns the profile of the user specified, and in your browser it looks like you are visiting www.mysite.com/someuser.

With apache you'd use the .htaccess file to accomplish this along with PHP's $_GET variable.

It is also fully possible to write your own system for managing this, but you can be sure that they will not have a subfolder for every user.

I'll show you an example if you like.
 
If you were using .NET, there are various HTTP Modules available that you can implement by using REGEX to match string patterns are redirect to the correct url. It really isn't THAT difficult - I wrote a similar module a few months ago.
 
Top
Sign up to the MyBroadband newsletter
X