[英]Codeigniter url management for two ends i.e End User & Admin
Basically i wants to distinguish my URL for end user and admin. 基本上,我想区分最终用户和管理员的URL。
As per CodeIgniter rule url works as 根据CodeIgniter规则,URL的作用如下
www.mysite.com/[controller]/[method]
1) Url management for End User 1)最终用户的网址管理
when a user see my page url should be same as codeigniter rule ie 当用户看到我的页面网址应与codeigniter规则相同,即
www.mysite.com/[controller]/[method]
2) Url management for Admin 2)管理员的网址管理
But i wants to add a unique segment /control/
to serve for admin like 但是我想添加一个唯一的段
/control/
来为管理员服务
www.mysite.com/control/[controller]/[method]
basically here i just wants to add a segment to distinguish my admin access from end user 基本上在这里我只想添加一个细分来区分我的管理员访问权限和最终用户
rewrite rules
in .htaccess
as
.htaccess
使用一些rewrite rules
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
if it is possible please provide me a solution 如果可以的话请给我一个解决方案
Thank you very much 非常感谢你
If you only want the URL to look different, you can add this to your config/routes.php file: 如果只希望URL看起来不同,可以将其添加到config / routes.php文件中:
$route['control/([a-z]+)'] = '$1/index'; //edited in for default index access
$route['control/([a-z]+)/([a-z]+)'] = '$1/$2'; // $1 = controller, $2 = method
Or you can add an actual folder "control" in your controllers folder, and put any admin-related controllers in there; 或者,您可以在controllers文件夹中添加一个实际的文件夹“ control”,并在其中放置任何与管理员相关的控制器; ie have your URL structure reflect your controller folders structure.
即让您的URL结构反映您的控制器文件夹结构。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.