I have to build a function for create clients. When I register a new client, each one of them should have its own detail page.
For Example, Coca Cola: When I register "cocacola" client, I have to build a link: www.dominio.com/cocacola
.
If the client is BMW, the link shoul开发者_开发百科d be www.dominio.com/bmw
.
I'm using PHP5, mysql, apache.
Any help?
regards, barcelona23
Feel free to checkout mod_rewrite. It can rewrite a given URL to map to a script with query parameters.
http://dominio.com/DynamicPathPart ==> http://dominio.com/yourscript.php?path=DynamicPathPart
From there it's just pure PHP.
To tame the beast that is mod_rewrite turn to a friendly tutorial. Here's one I've used:
http://articles.sitepoint.com/article/guide-url-rewriting
In this case use mod_rewrite. Example:
RewriteEngine on
RewriteRule ^([^/\.]+)/?$ /index.php?client=$1 [L]
This would take the first parameter and send it to the index.php page with the parameter client set to the client entered.
So the user would see this www.dominio.com/cocacola
and behind the scenes would be this www.dominio.com/index.php?client=cocacola
Then in your index.php page you can access the set client by using $_GET['client']
Here is a good tutorial on mod_rewrite
精彩评论