Skip to content Skip to sidebar Skip to footer

Passing Parameters In The Url (not With Php Get)

Possible Duplicate: mod rewrite and query strings The only way I know to pass parameters in the URL is using the GET method in PHP. But I saw many websites using what seems to b

Solution 1:

This is called url rewriting. Basically this means that you use an apache module to rewrite incoming urls to new urls which are then handled by apache

In your example http://www.test.com/page/2/ is probably rewritten to something like http://www.test.com/?page=2.

If you search the internet for Apache URL rewrite you will get enough results explaining how you can do this.

Solution 2:

These are all conventions. GET parameters are not specific to PHP, this is how all browsers encode form data. Java-based webapps use semicolon-separated parameters for example.

You can write a simple layer to convert ?alpha=1&beta=2 to /alpha/1/beta/2 but iw tould be just a cheap gimmick (except in a very few legitimate cases like with Squid caches).

What today's websites do is to use a single entry point pattern. Usually with apache's mod_rewrite, all requests are handled by the index.php and there is a routing facility to choose the adequate handler PHP file for a specific URL scheme. These schemes can be easily defined by Regular Expressions.

So all in all you decide how your URLs are going to look like. It is not an easy task and there are many SEO snake oil salesmen out there who will make you do all kinds of crazy stuff. What a good URL does is to identify a content (document) inside your service and you must use that single URL throughout your service to address it.

And don't forget: cool URLs don't change. You will abandon your current code base in 2 years and rebuild your site from the ground up. Design your URL scheme in a way that makes sense from a logical point of view and not something dependent on your webapp design.

Solution 3:

The example you gave is still a GET request.

What you are looking for is URL rewriting.

Post a Comment for "Passing Parameters In The Url (not With Php Get)"