开发者

How to Route URLS in PHP?

I would like to achieve what Facebook has simply done with url mechaniscm. facebook.com/user leads to the a users profile page and facebook.com/page leads to a page. I would like to know how this routing is done with the first URL?

I have the basic idea. Filter selected tables for matches and selected the appropriate one if the record exists!! But whats the best way which will minimize loa开发者_StackOverflowd and all.


Use a framework such as Kohana or symfony which already have this kind of URL routing that they handle automatically. However, if you are talking about minimizing loads, a framework is not the way to go.

You can update your .htaccess to handle these requests and redirect:

RewriteEngine on
RewriteRule ^.*$ /index.php?request=$0

Then you use php to handle _REQUEST[request] however you like.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜