Codeigniter:我想为用户创建用户名时为他们创建用户URL [英] Codeigniter: I would like create user URL's for my users when they create a username

查看:90
本文介绍了Codeigniter:我想为用户创建用户名时为他们创建用户URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望为用户注册用户名时为他们创建这种URL mysite.com/username

I wold like to create this kind of URL for my users when they register a username mysite.com/username

我在该网站上搜索了很多帖子,并且看到有人这样做,例如mysite.com/user/username

I've search many posts on this site and I see people doing it like this mysite.com/user/username

我想摆脱用户,直接将其转到mysite.com/username

I would like to get rid of the user and just have it go directly to mysite.com/username

什么是最好的方法?

推荐答案

我对CodeIgniter并不熟悉,但这是人们为什么不使用mysite.com/username的一般答案:

I am not familiar with CodeIgniter but here is a general answer for why people don't use mysite.com/username:

mysite.com/user/username是一个很好的解决方案,因为通常URL调度程序会将用户名传递给处理用户页面的功能/模块.

mysite.com/user/username is a good solution because usually the URL dispatcher passes username to a function/module that handles users' page.

mysite.com/username是一个不好的解决方案,因为您的调度员必须在所有其他规则之后都设置一个贪婪的规则,才能将那些先前规则以外的所有其他内容传递给处理用户页面的模块/功能.

mysite.com/username is a bad solution because your dispatcher will have to have a greedy rule after all your other rules, to pass everything other that those previous rules to the module/function that handles users' page.

现在,假设您要使用mysite.com/username,并假设您拥有mysite.com/logout,它将用户带到注销页面.用户来并使用注销"作为其用户名注册自己.那么,您要访问mysite.com/logout怎么说呢?logout先生想注销还是要查看他的页面?

Now suppose you want to use mysite.com/username and suppose you have mysite.com/logout which lands users to the logout page. A user comes and registers himself with "logout" as his username. Then how are you going to say by accessing mysite.com/logout Mr. logout wants to logout or wants to see his page?

这篇关于Codeigniter:我想为用户创建用户名时为他们创建用户URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆