[英]How to hide data from URL string on Codeigniter
I am beginner on Codeigniter
so I need help.我是
Codeigniter
的初学者,所以我需要帮助。
I am making blog site with Codeigniter
and I don't know how to hide controller class, and ID from URL.我正在使用
Codeigniter
制作博客网站,但我不知道如何隐藏 controller class 和来自 ZE6B3231A8D2B65D84579 的 ID。
Like I have generated following URL: http://localhost/codeigniter/index.php/content/some-title/123 .就像我生成了以下 URL: http://localhost/codeigniter/index.php/content/some-title/123 。
content
is my controller class name. content
是我的 controller class 名称。some-title
is my article title. some-title
是我的文章标题。123
is my article id. 123
是我的文章ID。 I want to keep only title to show.我只想保留要显示的标题。
For example: http://localhost/codeigniter/index.php/some-title .例如: http://localhost/codeigniter/index.php/some-title 。
Any help would be appreciated!!!任何帮助,将不胜感激!!!
You has add your link config/routes.php
您已添加链接
config/routes.php
http://localhost/codeigniter/index.php/content/some-title/123 HTTP://localhost/codeigniter/index.php/content/some-title/123
Ex: $route ['some-title/(: any)'] = 'content/some-title/$123';
You can do this: 你可以这样做:
$route['(:any)'] = 'content/view/$1';
and in your content controller you must have a method like the one follow: 并且在您的内容控制器中,您必须具有如下所示的方法:
public funtion view($pagetitle){…}
In the routes.php make sure you are using this line after your other routes which starts with some text.在 routes.php 中,确保在其他以一些文本开头的路由之后使用此行。
$route['(:any)'] = 'content/show_article_post/$1';
Also make sure your slug for each article is unique in your database.还要确保每篇文章的 slug 在数据库中都是唯一的。 There is no other way to send hidden id from get request.
没有其他方法可以从 get 请求中发送隐藏的 id。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.