dsfovbm931034814
dsfovbm931034814
2017-09-26 22:45

如何使用路由仅使用文件夹名称访问控制器

  • codeigniter
  • php

How to access controller only with folder name, folder exist in controller. Folder name is admin inside controller folder. Controller is dashboard(php file) inside admin folder.

$route['admin/(:any)']  = 'admin/dashboard';

htaccess

RewriteEngine on
RewriteCond $1 !^(index\.php|(.*)\.swf|forums|images|css|downloads|jquery|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?$1 [L,QSA]

I want to access dashboard(php file) using: http://Website/admin. But not working.I thnik, I have issue with above route line. enter image description here

Working route

$route['(:any)'] = "admin/dashboard";

Using $route['(:any)'] page can access with: http://Website/any-string-or-letter. But how to access only with: http://Website/admin.

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答

为你推荐