.htaccess twitter或facebook URL命名约定
【腾讯云】亏本大甩卖,服务器4核16G 1年370元(带宽12M,系统盘120GB SSD盘,月流量2000GB)!!!!!!
云产品 配置 价格
服务器 1核2G,带宽5M,系统盘50GB SSD盘,月流量500GB 38元/年
MySQL 1核1G 19元/年
服务器 16核32G,带宽18M,系统盘250GB SSD盘,月流量5000GB 1197元/年
点我进入腾讯云,查看更多详情

For my Social Networking Site, I would like to build a facebook, or twitter similar URL rewriting naming convention.

Using Twitter as an example, they have pages labeled twitter.com/about and another page labeled twitter.com/{$username}

However, how do you differentiate between say a user who has registers on to our site as "about" then. From this we are going to have a server conflict between the user "about" and the page about.

What is the best way to handle this?

#0

What our final decision came down to, was upon requesting a page on our server mysite.com/user, it first checked to see if that was a page, if it IS NOT a page, it assumes that it is a user, in which case it checks to see if that user is an object, if it is not then it gets passed to our 404 page.

So ontop of this, we are going to use the HTTP request like you mentioned earlier, and then if some how user "about" still signs up which we now have a page for, essentially sucks to be him because he is not going to see his page.

#1

Usually, you'll see this implemented so that conflicts are not possible. For instance, you could camp all users inside a virtual /users directory, or a subdomain: mysite.com/users/msilvis, or users.mysite.com/msilvis.

I would not recommend that you make all users accessible via the root directory of your site, because this could potentially restrain you from adding pages. For instance, suppose you do not have yet an "about" page, but a user registers and calls itself "about"; you're screwed.

If you still choose to do so, before registration, try an HTTP request to your website to the page the user would have. If you don't get a 404, then something already has that name.

#2

I would restrict the ability for someone to create a username that would conflict with existing urls.

#3

If you're still in the early stages of development, you could look at the Kohana PHP framework. It's routing features solve the problem highlighted by zneak and dd, you would simply define in your routes that http://yoursite.com/about would point to a particular controller/action, i presume you're using the MVC design pattern considering you want a twitter like url structure.

Hope that helps!

EDIT: I forgot to mention that this doesn't stop people from signing up as about, it would just prevent the rest of the world from being linked to that persons page, in order to prevent them you'd need to employ some kind of validation against your core pages aka about, contact ect.

推荐文章

jQuery$(“*”).fadeTo()在淡入之前移动内容

jQuery$(“*”).fadeTo()在淡入之前移动内容

推荐文章

从c访问目标c++

从c访问目标c++

推荐文章

在Visual Studio中使用调试器可视化工具而不必将其dll程序集复制到VS的文件夹

在Visual Studio中使用调试器可视化工具而不必将其dll程序集复制到VS的文件夹

推荐文章

如何从碎宝石中恢复?

如何从碎宝石中恢复?

推荐文章

简单点:Expression4studio是最终版本,是吗?

简单点:Expression4studio是最终版本,是吗?

推荐文章

PHP中的Zip流

PHP中的Zip流

推荐文章

Vb.Net 2005的单元测试与Bug报告

Vb.Net 2005的单元测试与Bug报告

推荐文章

有人知道跟踪多个项目和资源的软件吗?

有人知道跟踪多个项目和资源的软件吗?

推荐文章

preg_替换为花括号

preg_替换为花括号

推荐文章

Haskell中的HTTP POST内容

Haskell中的HTTP POST内容

推荐文章

如何说服团队中的程序员执行TDD?

如何说服团队中的程序员执行TDD?

推荐文章

Dalvik内存分配-如何更改默认限制?

Dalvik内存分配-如何更改默认限制?

推荐文章

从temp_name=something的表中选择作为temp_name?

从temp_name=something的表中选择作为temp_name?

推荐文章

如何使用?字符串的关键字

如何使用?字符串的关键字

推荐文章

带有$sign的msql表名

带有$sign的msql表名

推荐文章

Rails 2中具有不同has-one关联的急切加载多态关联

Rails 2中具有不同has-one关联的急切加载多态关联