- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我已经阅读了有关 URI 路由和 View 的手册,但有些地方并没有引起我的兴趣。
在我的 views 文件夹中,我有一个名为 products 的子文件夹。其中有一个名为 product_view 的文件。在我的 Controller 中,我有:
function index() {
$data['title'] = 'Product Overview';
$data['main_content'] = 'products/product_view';
$this->load->view('templates/main.php', $data);
}
模板加载一个页眉 View 、一个页脚 View 和一个导航 View ,加上作为主要内容变量的 View 。
在我的 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]
我很感激一些具体的帮助,因为文档没有具体说明如何解决这个问题。我在论坛上做了一些搜索,没有看到任何东西,但我在继续寻找的同时发布了这个。
最佳答案
在 CI 中,URI 由您的 Controller 名称和 Controller 中的方法名称路由。
如果 Controller 名为“products.php”,相应 View 的函数称为“index”,该页面的正确 URI 为“/products”。
所以你的代码应该是
$route['products/product-overview'] = 'products/index';
关于php - CodeIgniter 子文件夹和 URI 路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4564025/
使用 ruby 1.9.2-p290。我在尝试解析如下 URI 时遇到问题: require 'uri' my_uri = "http://www.anyserver.com/getdata?anyp
根据 http://tools.ietf.org/html/rfc3986和 http://en.wikipedia.org/wiki/Uniform_resource_identifier , UR
如何在文本 block 中发现 URI? 这个想法是将这样的文本运行变成链接。如果只考虑 http(s) 和 ftp(s) 方案,这很容易做到;但是,我猜测一般问题(考虑 tel、mailto 和其他
我的一些网址上有一些特殊字符。例如: http://blabla.com/title/?t=burası 当我从其他页面提供指向该页面的链接时,我使用: URI.encode(s) 产生这个链接: /
我在 Windows Mobile 上使用紧凑型框架/C#。 在我的应用程序中,我通过序列化对象并使用 HttpWebRequest/POST 请求向上发送信息来将数据上传到服务器。在服务器上,发布数
我正在做一个实验,我发现将 Canvas 转换为 blob,然后转换为数据 URI 会导致与直接从 Canvas 获取数据 URI 不同的 URI。打开时的内容在两个 URI 上几乎相同。 使用 bl
我正在尝试在 Rails 3 中实现 OAuth 提供程序。当我尝试授权客户端应用程序时,出现此错误。我正在使用 RESTful auth 插件和 pelles OAuth 插件。当我通过 Rails
我有一个编码的 UI 测试方法: public void MyTestMethod() { string baseUrl = "www.google.com"; GlobalVaria
我知道这是一个常见的错误,我正在使用一个已知的解决方案,但它仍然给我同样的错误: require 'open-uri' url = "http://website.com/dirs/filex[a]"
我正在尝试使用 .NET 中的 HttpClient 来使用 Web 服务,并且在我完成了 msdn 中提到的所有步骤之后 o 出现以下异常:提供了无效的请求 URI。请求 URI 必须是绝对 URI
我正在尝试检索文件的 URI。该文件存储在: /storage/emulated/0/AppName/FileName.png 如果我使用 Uri.fromFile(file),我得到的是 file:
我想知道 (SIP) URI 中的不同参数分隔符表示什么? 部分以;分隔,例如: . 其他用?隔开和 & ,例如: 最佳答案 SIP 分隔符规则来自RFC 2396 RFC 3986 已弃用.但是在
我想调用decodeUrl(...),我这样做是: import "dart:uri"; main() { decodeUrl("str"); } 但是现在有了最新的Dart-SDK,它会报告
在 URI 中,空格可以编码为 + .既然如此,那么在创建具有国际前缀的 tel URI 时是否应该对前导加号进行编码? 哪个更好?两者在实践中都有效吗? Call me Call me 最佳答案 不
我试图弄清楚电子邮件地址的格式是否可以说符合 URI 的定义,但到目前为止我还没有找到明确的确认。我希望有人可以在这里为我提供一些见解。预先感谢:) 最佳答案 是的,但带有“mailto:”前缀。 U
因此,我尝试将 ID 参数附加到 URI 的末尾,当用户单击我的列表中的项目时,用户将被发送到该 URI。我的代码如下: public void onItemClick(AdapterView par
这是 Converting file path to URI 的后续问题. 考虑: require 'uri' uri = URI.join('file:///', '/home/user/dir1/
我在 pl/sql 中创建了一个名为 tester 的包。但我收到以下消息。 绝对URI中的相对路径:java.net.URI.checkPath(URI.java:1823) --Package D
我在 gitlab 上有一个 git repo,使用私有(private) pod 和其他公共(public) pod,下面是我的 Podfile source 'git@gitlab.mycompa
我正在尝试将我的 Rails 应用程序推送到 heroku 上,我正在使用 heroku RedisToGo 附加组件我经历过这个tutorial并完成了那里提到的所有步骤。 但是在推送 heroku
我是一名优秀的程序员,十分优秀!