search
HomeBackend DevelopmentPHP ProblemHow to remove ci's index.php
How to remove ci's index.phpNov 03, 2020 am 11:38 AM
ciindex.php

去掉ci的index.php的方法:首先打开apache的配置文件;然后将相关htaccess的相关信息改为“AllowOverride All”;接着在CI的根目录下,建立htaccess;最后重启apache即可。

How to remove ci's index.php

推荐:《PHP视频教程

去掉CodeIgniter(CI)默认url中的index.php的步骤:

1.打开apache的配置文件,conf/httpd.conf :

LoadModule rewrite_module modules/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_demo_1/index.php/

第三行需要改写为

RewriteRule ^(.*)$ /CI/index.php/$1 [L]

另外,我的index.php的同级目录下还有assets文件夹,这些需要过滤除去,第二行需要改写为:

RewriteCond $1 !^(index\.php|images|assets|robots\.txt

3.将CI中配置文件(application/config/config.php)中

$config[ 'index_page' ] =  "index.php" ;

改成

$config[ 'index_page' ] =  "" ;

重启apache,完成。

=========================================================================================================================

php 框架ci去index.php的方法

网上有很多方法都要引入.htaccess文件,如果是在测试环境下,动态和静态的文件放到一块,可能测试会有一定的问题(由于全部定向到index.php),静态网页访问不了。

这里提供一种方法,只需要修改http.conf文件,

步骤:

1 :在配置虚拟目录下加入 

<Directory />
      Options Indexes FollowSymLinks
      AllowOverride all
      Order allow,deny
      Allow  from  all
    </Directory>
    <IfModule mod_rewrite.c>
     RewriteEngine  on
     RewriteRule ^/script/(.*) /script/$1 [L]
     RewriteRule ^(.*)$ /index.php?/$1 [L]
    </IfModule>

2 将下面这行前面的;去掉

LoadModule rewrite_module modules/mod_rewrite.so

3 重启apache就可以了,无需加入.htaccess文件

The above is the detailed content of How to remove ci's index.php. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
CI vs Laravel:哪个框架更适合构建博客或CMS网站?CI vs Laravel:哪个框架更适合构建博客或CMS网站?Jun 19, 2023 am 08:54 AM

随着网站建设的不断发展和升级,选择适合自己的框架已经成为建站者必备技能。本文将对CI和Laravel进行简要分析,帮您选出更适合构建博客或CMS网站的框架。一、CI介绍CodeIgniter,简称CI,是一个开源的轻量级web应用程序开发框架,采用MVC架构模式。CI可运行于PHP5.2及以上版本,并包含了许多常用的库和帮助函数,使得使用CI开发web应用程

探索PHP框架的创新功能:从CI到Yii探索PHP框架的创新功能:从CI到YiiNov 27, 2023 am 10:04 AM

随着互联网的快速发展,PHP语言的应用越来越广泛。为了提高开发效率、降低开发成本和采用最佳实践,PHP框架应运而生。其中,CodeIgniter(CI)和Yii是两个知名的PHP框架。本文将从创新功能的角度来探索这两个框架。CodeIgniter(CI)是一个轻量级的PHP框架,它被广泛使用于Web应用程序的快速开发。CI的主要特点是简单易用、快速和灵活。在

tp3怎么隐藏index.phptp3怎么隐藏index.phpMar 03, 2023 am 10:18 AM

tp3隐藏index.php的方法:1、找到并打开“Application/Common/Conf/config.php”文件;2、通过修改“return array('URL_MODEL'=> 2,);”开启REWRITE模式即可。

lnmp 怎么隐藏index.phplnmp 怎么隐藏index.phpOct 21, 2022 am 10:12 AM

lnmp隐藏index.php的方法:1、打开“location ~ [^/].php”文件;2、修改内容为“location ~ [^/].php”;3、去掉“#try_files $uri =404;”前面的#符号;4、添加“rewrite "^/(.*)$" /index.php last;”内容;5、重启Nginx即可。

如何与持续集成 (CI) 结合使用 C++ 函数单元测试?如何与持续集成 (CI) 结合使用 C++ 函数单元测试?Apr 24, 2024 pm 03:42 PM

答案:使用持续集成(CI)与C++函数单元测试结合可以自动化代码测试、保障代码质量和可靠性。安装CMake和单元测试框架:GoogleTest:sudoaptinstalllibgtest-devCatch2:sudoaptinstalllibcatch2-dev编写单元测试:使用单元测试框架(如GoogleTest)编写代码测试配置CMake:在CMakeLists.txt中添加单元测试在CI中运行测试:配置CI系统(如Jenkins)在每次推送时运行测试

php如何使用CI5框架?php如何使用CI5框架?May 31, 2023 pm 03:31 PM

随着Web开发技术的不断发展,使用框架成了现代开发者的日常工作之一。其中,CI框架因其简单易用而受到了广泛的关注。本文将向读者介绍CI5框架的使用方法,以及如何在PHP开发中灵活运用。一、什么是CI5框架CI5框架(CodeIgniter5)是一款以MVC设计模式为基础的Web应用程序框架,使用PHP语言开发。CI5框架的主要目标是为了快速开发Web应用程序

https URL中怎么去除index.phphttps URL中怎么去除index.phpMar 20, 2023 pm 03:35 PM

在许多网站的 URL 中,经常会出现 index.php 的字符串。尽管这个文件非常重要,但有时用户希望将此字符串从他们的 URL 中去除,以使网站结构更清晰。

服务器中怎么去掉index.php服务器中怎么去掉index.phpDec 19, 2022 am 10:24 AM

服务器中去掉index.php的方法:1、打开php.ini文件,更改内容为“cgi.fix_pathinfo=1”;2、修改对应虚拟主机的配置文件;3、将“include enable-php.conf;”替换为“include enable-php-pathinfo.conf;”;4、去掉index.php,重启lnmp即可。

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.