phpciurl
❶ php ci 框架可以吧url中的斜杠换成-
1 修改 apache 的 httpd.conf 文件
#LoadMole rewrite_mole moles/mod_rewrite.so
去掉前面的#
2 找到 你程序目录下的 .htaccess 文件
内容如下
<IfMole mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfMole>
保存 ,重启就好了
❷ 关于php ci框架ie浏览器路径问题
<scripttype="text/javascript"src="<?phpechobase_url('/js/homepage.js');?>"></script>
像这样即可
❸ 在ci框架中如何获取上一个页面的url
你可以用php源码 $_SERVER['HTTP_REFERER']函数获取上一页面的url
❹ php CI框架中的 $this->uri->segment(); 是什么意思啊
获得URL上的参数
比如:...index.php/controller/index/3
$this->uri->segment(3);就是url上从index.php开始往后数,/划分,例子上就是得到的3
❺ windows下 php+CI+apache 怎么删除URL路径中的index.php
默认情况下,index/index.php/news/article/my_article 你可以很容易的通过 .htaccess 文件来设置一些简单的规则删除它。下面是一个例子,使用“negative”方法将非指定内容进行重定向: RewriteEngine on RewriteCond $1 !^(index\.phpimagesrobots\.txt) RewriteRule ^(.*)$ /index.php/$1 [L] 注意:如果你的项目不在根目录请把上面这一句改为:RewriteRule ^(.*)$ index.php/$1 [L] 在上面的例子中,可以实现任何非 index.php、images 和 robots.txt 的 HTTP 请求都被指向 index.php。 我的终极解决方案 但在实践中,以上方案仅适用于与运行于Apache环境下的服务器且并不具有充分的普遍适用性!当CI程序位于非根目录或位于某些虚拟主机上时,以上解决方案会引起”404错误”或”no input file specified”等错误.网络参考过相关问题的解放方案后,找到了一种具有通用性的有效删除URL路径中index.php的方法,代码参考如下: index位于根目录时,你可以在index.php所在的根目录里新建.htaccess文件并使用以下代码: RewriteEngine on RewriteCond $1 !^(index\.phprobots\.txt) RewriteRule ^(.*)$ /index.php?/$1 [L] 当index.php不在根目录时,你可以在index.php所在目录里新建.htaccess文件并使用以下代码: RewriteEngine on RewriteCond $1 !^(index\.phpimagesrobots\.txtl) RewriteRule ^(.*)$ /path_to_app/index.php?/$1 [L] 注意把path_to_app换成你的index.php所在文件的目录.假设你的index.php放在根目录的tool子文件夹下,你可以这样写: RewriteEngine on RewriteCond $1 !^(index\.phpimagesrobots\.txtl) RewriteRule ^(.*)$ /tool/index.php?/$1 [L] 以上方案应该可以解决Apache环境下如何有效删除URL中index.php的问题,
❻ php怎么办url中的index.php去掉
为美观一些,去掉CI默认url中的index.php。分三步操作:
1.打开apache的配置文件,conf/httpd.conf :
LoadMole rewrite_mole moles/mod_rewrite.so,把该行前的#去掉。
搜索 AllowOverride None(配置文件中有多处),看注释信息,将相关.htaccess的该行信息改为AllowOverride All。
2.在CI的根目录下,即在index.php,system的同级目录下,建立.htaccess,直接建立该文件名的不会成功,可以先建立记事本文件,另存为该名的文件即可。内容如下(CI手册上也有介绍):
RewriteEngine on
RewriteCond $1 !^(index/.php|images|robots/.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
如果文件不是在www的根目录下,例如我的是:http://localhost/CI/index.php/,第三行需要改写为RewriteRule ^(.*)$ /CI/index.php/$1 [L]。
另外,我的index.php的同级目录下还有js文件夹和css文件夹,这些需要过滤除去,第二行需要改写为:RewriteCond $1 !^(index/.php|images|js|css|robots/.txt)。
3.将CI中配置文件(system/application/config/config.php)中$config['index_page'] = "index.php";将$config['index_page'] = ""; 。
ok,完成。还要记得重启apache。
❼ php ci 当用户在url加个get参数 并且这个get的值不存在时怎么显示404
可以在控制器里实现。
通过 $this->input->get() 数据。
判断get得到的数据 是否存在,如果为空 自己写个 跳转函数 跳转页面提示404即可。
❽ 在nginx下如何去除ci框架url中的index.php
ci框架默认的url规则中带有应用的入口文件,例如:
example.com/index.PHP/news/article/my_article
在以上URL中带有入口文件index.php,这样的URL规则对搜索引擎来说是不友好的,那么如何去除这个index.php?
步骤
1 apache环境下:
通过 .htaccess 文件来设置一些简单的规则删除它。下面是一个例子,使用“negative”方法将非指定内容进行重定向:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
2 如果项目不在根目录请把上面这一句改为:RewriteRule ^(.*)$ index.php/$1 [L]
在上面的例子中,可以实现任何非 index.php、images 和 robots.txt 的 HTTP 请求都被指向 index.php。
Nginx环境下:
修改nginx配置文件,在SERVER段中添加如下代码:
location /{
if (-f $request_filename) {
expires max;
break;
}
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1 last;
}
}
❾ php的CI框架如何实现异步调用
在你自定义的类库中初始化CodeIgniter资源
要你自定义的类库中访问CodeIgniter的原始资源,你必须使用 get_instance() 函数.这个函数返回一个CodeIgniter super object.
一般来说在你的控制器函数中你可以通过 $this 调用任何可用的CodeIgniter函数:
$this->load->helper('url');
$this->load->library('session');
$this->config->item('base_url');
//etc.
$this, 只直接作用在你自己的控制器,模型和视图中.当你在自定义类中想使用CodeIgniter原始类时,你可以这样做:
首先,定义CodeIgniter对象赋给一个变量:
$CI =& get_instance();
一旦定义某个对象为一个变量,你就可以使用那个变量名 取代 $this:
$CI =& get_instance();
$CI->load->helper('url');
$CI->load->library('session');
$CI->config->item('base_url');
//etc.
注意: 你将注意到get_instance()这个函数通过被引用的方式被传递:
$CI =& get_instance();
这十分重要. 通过引用的方式赋给变量将使用原始的 CodeIgniter 对象,而不是创建一个副本。
//------------------------------------------------------------------------------------------------//
我想这也许是你需要的.$CI =& get_instance();之后再用$CI->load->library('session');等方法加载你需要的
❿ CI框架如何删除URL中index.php的终极解决方案
默认情况下,index.php 文件将被包含在你的 URL 中:
example.com/index.php/news/article/my_article
你可以很容易的通过 .htaccess 文件来设置一些简单的规则删除它。下面是一个例子,使用“negative”方法将非指定内容进行重定向:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
注意:如果你的项目不在根目录请把上面这一句改为:RewriteRule ^(.*)$ index.php/$1 [L]
在上面的例子中,可以实现任何非 index.php、images 和 robots.txt 的 HTTP 请求都被指向 index.php。
我的终极解决方案
但在实践中,以上方案仅适用于与运行于Apache环境下的服务器且并不具有充分的普遍适用性!当CI程序位于非根目录或位于某些虚拟主机上时,以上解决方案会引起”404错误”或”no input file specified”等错误.网络参考过相关问题的解放方案后,找到了一种具有通用性的有效删除URL路径中index.php的方法,代码参考如下:
index位于根目录时,你可以在index.php所在的根目录里新建.htaccess文件并使用以下代码:
RewriteEngine on
RewriteCond $1 !^(index\.php|robots\.txt)
RewriteRule ^(.*)$ /index.php?/$1 [L]
当index.php不在根目录时,你可以在index.php所在目录里新建.htaccess文件并使用以下代码:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txtl)
RewriteRule ^(.*)$ /path_to_app/index.php?/$1 [L]
注意把path_to_app换成你的index.php所在文件的目录.假设你的index.php放在根目录的tool子文件夹下,你可以这样写:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txtl)
RewriteRule ^(.*)$ /tool/index.php?/$1 [L]
以上方案应该可以解决Apache环境下如何有效删除URL中index.php的问题,