如何从codeigniter中的URL中删除id

时间:2015-02-10 04:41:02

标签: php codeigniter

我当前的网址是
http://localhost/news/user/user_profile/16

http://localhost/news =是基本网址

/ user / =是控制器名称

user_profile =是函数名称

这是链接

<a href="<?php echo base_url().'user/user_profile/'.$id;?>" class="btn btn-default btn-flat">Profile</a>

16 =是用户ID

我想从网址中删除用户ID

所以我想要这样的网址

http://localhost/news/user/user_profile

请帮助......

1 个答案:

答案 0 :(得分:0)

这取决于您的使用方式。

如果您想显示自己的个人资料或登录用户个人资料。 您可以使用该链接。 http://localhost/news/user/user_profile 其中id将是会话中记录的用户ID ..

在其他情况下,如果您想显示其他用户的个人资料,例如facebook个人资料。你必须在网址中输入id或slug。这是最好的方法。

http://localhost/news/user/user_profile/(id)http://localhost/news/user/user_profile/(slug-name)

仍然需要像http://localhost/news/user/user_profile/这样的网址 意味着您必须为每个链接使用表单并为每个请求提交表单,并将id作为post方法,我不会推荐这种方式。

相关问题