问题标签 [codeigniter-url]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
49 浏览

codeigniter - 为什么 regex 不会在 CodeIgniter 中传递参数?

当我查看我的编辑器控制器时,在 index 方法中,我没有通过参数。它只是说“$ 1”

0 投票
2 回答
5198 浏览

url - 在 Codeigniter 中加密 uri 段

我想加密我的 uri 段,这些段作为 ID 传递以查询到数据库表中。

例如我正在使用

这是在另一个控制器上使用解码

我已经测试了加密和解密,它似乎工作。但是在尝试网址时,例如。

在某些 url 上它会按预期工作,但在某些 url 上会出现浏览器错误 404(找不到对象)。在删除加密段时,我可以访问索引功能。这可能是什么原因?

0 投票
1 回答
1254 浏览

codeigniter - CodeIgniter 2.x 中控制器的多级子文件夹

我在 CodeIgniter 的网站上找到了这篇文章:http ://codeigniter.com/forums/viewthread/129469/ ,关于如何处理 CI 1.7.1 中的多级子文件夹,但 CI 2.x 改变了他们做事的方式。有人可以为我指出正确的方向,了解如何进行更改以使该脚本正常工作。我无法遵循旧代码下方的评论。我在 CI 的论坛上发帖,但我想我会在这里尝试一下,看看这里是否有人也可以提供帮助。我将不胜感激。谢谢。

0 投票
2 回答
2316 浏览

php - CodeIgniter URI Routing (htaccess) with multiple Applications

Hello stackoverflow community,

I've got a little Problem with my CodeIgniter. I use two applications in my app folder. The first one is the frontend, the second one the backend.

In my root directory I've two .php files. An index.php leading to the frontend directory and a backend.php leading to the backend directory.

Since I use mod rewrite in order to get clean URL's there is a problem with that. The URL structure is the following: www.domain.com/controller/action

That's the action of the controller in my frontend Application.

I use htacces to get rid of the /index.php/ between domain and controller. To access my backend application I want my URL to be like this www.domain.com/admin/controller/action

therefore I have this rewrite rule:

Now the problem: CodeIgniter assumes that /backend/ is the first URI segment, and wants to treat it mistakenly as my controller.

Do I really have to edit the core of CodeIgniter in order to tell it not to use the Server Request URI or is there another trick?

Thanks in advance, Thomas

0 投票
1 回答
338 浏览

codeigniter - CodeIgniter 控制器在函数调用中未正确解释连字符

我有一个奇怪的问题。我的控制器试图调用 uri 段并且没有正确解释连字符。我没有收到任何错误。只是调用之外的页面的其余部分不会呈现。这是针对 CMS 的,我在我的市场控制器中创建了一个 edit_market 函数。我希望能够调用页面的页面内容,该页面在数据库中由页面导航名称引用,该名称有时带有连字符(例如,消费品)。

这是我的控制器:

我的markets_materials_model:

这适用于所有没有连字符的链接,但当链接有连字符时会失败。这是什么原因造成的?我现在可以编辑这些页面的唯一方法是在我的 URI 中使用 edit_market,而不是创建一个包含“edit-market”的路由。我相信如果我没记错的话,直接访问控制器是一种不好的做法。

0 投票
1 回答
82 浏览

codeigniter - 在 codeigniter 中加载视图

嗨,我有一个名为 CIcontroller 的 codeigniter 控制器,我有一个方法说 redirectmethod

在重定向方法中我有一些代码,然后我这样做

模板视图基本上加载页眉页脚和数据参数指定的相应视图

现在一切正常,但我的网址有价值http:\\blabla\CIcontroller\redirectmethod而不是http:\\blabla\page_name

谁能帮我解决这个问题

0 投票
2 回答
1062 浏览

.htaccess - 使用 .htaccess 强制删除 index.php

我目前正在使用以下内容进行重写http://www.site.com/index.php/test/以直接使用http://www.site.com/test/,但我不仅想允许第二个版本,我还想强制第二个版本。如果用户去http://www.site.com/index.php/test/它应该立即将他们重新路由到http://www.site.com/test/. index.php 永远不应出现在 url 中。规定:这应该只适用于第一个 index.php。如果我有类似的标题http://www.site.com/index.php/2011/06/08/remove-index.php-from-urls/,则应保留第二个 index.php,因为它是 URL 的一部分。

当前允许但不强制的规则:#Remove index.php RewriteCond $1 !^(index.php|images|css|js|robots.txt) RewriteRule ^(.*)$ /index.php/$1 [L]

谢谢。

0 投票
2 回答
1482 浏览

php - 在 codeigniter 的编辑记录中加载视图

您好,我是 Codeigniter 的新手。我正在通过开发一个测试应用程序来学习这个框架。我正在显示用户列表,并在每条记录前面有一个锚标记来编辑该记录。那个锚标签看起来像

它将浏览器重定向到第一个控制器和 edit_user 函数。在 edit_user 函数中,我像这样加载编辑视图。

它加载关于所选记录的视图以编辑记录,并且 url 看起来像

每件事都很好。但是,当用户单击更新按钮时,它再次出现相同的功能。它更新记录,然后再次尝试加载相同的视图,但这里出现问题。现在更新记录后它会加载视图和 url 变成这样

它会产生错误,因为它没有所选记录的 id。如果我像这样更改我的函数的加载视图代码

它会产生一个错误,edit_user/.php 未定义,诸如此类。现在我想问我如何将用户重定向到相同的编辑表单,告诉他他的记录已经更新?如何从控制器的功能中加载所选记录的视图?

0 投票
4 回答
4171 浏览

php - Codeigniter url 路径

这是我可以问这个问题的最简单的方法,因为我还没有完全理解发生了什么,或者我做错了什么。

我的网址有问题。

http://localhost/index.php/user 相同 http://localhost/ http://localhost/index.php/user/something 不同 http://localhost/something

我怎么做http://localhost/something

它必须是http://localhost/user/something,我如何使它工作?

0 投票
1 回答
1956 浏览

javascript - 在codeigniter错误中使用jquery加载页面内容

我有一个主页,其中有几张表,每隔几秒就会刷新一次。

下面是视图文件 (inside_view.php) 中 jquery 的代码

这是控制器代码(inside.php)

这是(ajax_home_en.php)代码

当我尝试使用此 URL http://mysite.com/inside查看此页面时,一切都很好

但是一旦我输入这个网址 http://mysite.com/inside/或这个http://mysite.com/inside/index

显示 inside() 视图而不是 home_en() 视图。n 将在框中连续刷新页面(并使我的 IE 停止响应)。

我不明白为什么在 URL 中添加“/”或 /index 会导致这样的错误,是我的 javascript 出现错误吗?

thx 先进!