php-CodeIgniter子文件夹和URI路由
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了php-CodeIgniter子文件夹和URI路由,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2910字,纯文字阅读大概需要5分钟。
内容图文
![php-CodeIgniter子文件夹和URI路由](/upload/InfoBanner/zyjiaocheng/653/bc345550f2e9421db968ab420824a8a0.jpg)
我已经阅读了有关URI路由和视图的手册,但并没有点击.
在我的views文件夹中,有一个名为products的子文件夹.其中有一个名为product_view的文件.在我的控制器中,我有:
function index() {
$data['title'] = 'Product Overview';
$data['main_content'] = 'products/product_view';
$this->load->view('templates/main.php', $data);
}
该模板加载页眉视图,页脚视图和导航视图,以及该视图作为主要内容变量.
在我的URI路由中,我有:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
| -------------------------------------------------------------------------
| URI ROUTING
| -------------------------------------------------------------------------
| This file lets you re-map URI requests to specific controller functions.
|
| Typically there is a one-to-one relationship between a URL string
| and its corresponding controller class/method. The segments in a
| URL normally follow this pattern:
|
| example.com/class/method/id/
|
| In some instances, however, you may want to remap this relationship
| so that a different class/function is called than the one
| corresponding to the URL.
|
| Please see the user guide for complete details:
|
| http://codeigniter.com/user_guide/general/routing.html
|
| -------------------------------------------------------------------------
| RESERVED ROUTES
| -------------------------------------------------------------------------
|
| There are two reserved routes:
|
| $route['default_controller'] = 'welcome';
|
| This route indicates which controller class should be loaded if the
| URI contains no data. In the above example, the "welcome" class
| would be loaded.
|
| $route['scaffolding_trigger'] = 'scaffolding';
|
| This route lets you set a "secret" word that will trigger the
| scaffolding feature for added security. Note: Scaffolding must be
| enabled in the controller in which you intend to use it. The reserved
| routes must come before any wildcard or regular expression routes.
|
*/
$route['default_controller'] = "index_controller";
$route['laser-configurator'] = "configurator";
$route['news-and-events'] = "news";
$route['products/product-overview'] = "products/product_view";
$route['scaffolding_trigger'] = "";
/* End of file routes.php */
/* Location: ./system/application/config/routes.php */
当我尝试转到domain.com/products/product-overview时,这会导致404错误.我是否需要对.htaccess进行处理?如果是这样,该怎么办?这是我的.htaccess:
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$index.php?/$1 [L,QSA]
非常感谢您提供一些具体的帮助,因为该文档并不专门介绍如何解决此问题.我在论坛上做了一些搜索,但没有看到任何内容,但我一直在发布此消息.
解决方法:
要为您的控制器使用多级目录结构,请使用this post中讨论的路由器扩展,我有时会使用它,并且可以保证它能正常工作.
内容总结
以上是互联网集市为您收集整理的php-CodeIgniter子文件夹和URI路由全部内容,希望文章能够帮你解决php-CodeIgniter子文件夹和URI路由所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。