导航:首页 > 编程语言 > ciphp去除indexphp

ciphp去除indexphp

发布时间:2022-04-23 00:53:08

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。

❷ ci怎么去掉index.php

在根目录添加.htaccess文件。 文件代码如下: RewriteEngine On RewriteCond %{REQUEST

❸ 求助,如何处理CI自带的index.php文件

你的目的是想去掉index.php在不同的服务器下就要用到那二个文件(这二个文件是重写地址),去掉index.php除了要那二个文件外还要设置$config['index_page'] = "index.php";改成$config['index_page'] = "";在config.php里改,这样即使用site_url()生成的地址也不会带index.php另外,如果你的服务器不支持URI重写就没法去掉index.php

❹ 怎么把中间的index.php 去掉

apache服务器的话,可以定义.htaccess文件,在apache的httpd.conf配置文件中开启url重写功能。
在.htaccess文件中定义重写规则,网络一下就有的。
如上,去掉index.php

❺ CI框架怎么去掉隐藏入口文件index.php

呵呵 新手吧
//$config['index_page'] = 'index.php';
$config['index_page'] = '';

改成这样就可以了 我也在学习

❻ 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的问题,

❼ 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的问题,

❽ 在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;
}
}

❾ phpCI框架 如何去掉默认index.php

下面是去掉index.php的操作
PHP CodeIgniter(CI)去掉 index.php - Langjun - 博客园
设置访问的默认路径是在
文件下,找到
$route['default_controller'] = "index"; 默认的为welcome 改为你的访问index.php之后的参数
我的访问首页

遇到类似的问题,你可以去后盾人平台看看的哦,里面的东西不错应该能帮你解决一些不明白的问题(❁´◡`❁)*

阅读全文

与ciphp去除indexphp相关的资料

热点内容
linux打包命令targz 浏览:996
抖音app是哪个 浏览:407
苹果app怎么上架 浏览:255
NA服务器地址 浏览:427
我的世界如何初始化服务器 浏览:97
哪个手机app天气预报最准 浏览:752
怎样把视频压缩至25m 浏览:570
vivox27文件夹怎么改变 浏览:727
新手玩狼人杀用什么app 浏览:615
pdf在线查看 浏览:954
安卓tv90如何关闭后台 浏览:683
php读取word乱码 浏览:755
minicom源码 浏览:1001
海尔冷柜压缩机 浏览:416
联通服务器如何调试信号 浏览:136
stata新命令 浏览:941
单调栈算法python 浏览:606
微信解压游戏怎么下载 浏览:962
忍三服务器不同如何登上账号 浏览:822
php求积 浏览:297