当我重新接触一个框架的时候首先肯定要去掉入口文件,也就是index.php 这个东西在url上很不漂亮,而且每次我访问我的网站的时候都要打进去url里面。这样告诉一个去掉 CI框架里面入口文件的方法,其实也就是添加一个重定向操作。很多框架的操作的大同小异。

言归正转….

1.

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/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'] = ”"; 。

这样就可以了,不过千万记得从启apache。

如上的重定向规则在linux下也可以写成一个.htacess文件。放到网站的根目录。

转载请注明来源:CI 框架怎么去掉隐藏入口文件 index.php
http://www.php1.cn/Content/CI_KuangJiaZenMeQuDiaoYinCangRuKouWenJian_index-php.html

CI 框架怎么去掉隐藏入口文件 index.php的更多相关文章

  1. ThinkPHP5.X PHP5.6.27-nts + Apache 通过 URL 重写来隐藏入口文件 index.php

    我们先来看看官方手册给出关于「URL 重写」的参考: 可以通过 URL 重写隐藏应用的入口文件 index.php ,Apache 的配置参考: 1.http.conf 配置文件加载 mod_rewr ...

  2. CI隐藏入口文件index.php

    1.需要apache打开rewrite_module,然后修改httpd.conf的AllowOverride none 为AllowOverride All(里面,不同的环境目录不同) 2.在CI的 ...

  3. 【apache】phpstudy中apache 隐藏入口文件index.php (解决no input file specified错误)

    步骤: 下面我说下 apache 下 ,如何 去掉URL 里面的 index.php 例如: 你原来的路径是: localhost/index.php/Index/index改变后的路径是: loca ...

  4. Apache 隐藏入口文件 index.php

    新建 .htaccess文件至站点目录下,并写入如下代码: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQ ...

  5. nginx隐藏入口文件index.php

    网站的访问url可能是这样http://www.xxx.com/index.php/home/index/index 这种有点不美观,我们想达到如下效果http://www.xxx.com/home/ ...

  6. TP5 隐藏入口文件 index.php

    找到public下的.htaccess <IfModule mod_rewrite.c> Options +FollowSymlinks -Multiviews RewriteEngine ...

  7. niginx隐藏入口文件index.php

    location / { if (!-e $request_filename) { rewrite ^/(.*)$ /index.php/$ last; break; } }

  8. Nginx配置 隐藏入口文件index.php

    Nginx配置文件里放入这段代码 server { location / { index index.php index.html index.htm l.php; autoindex on; if ...

  9. Nginx如何来配置隐藏入口文件index.php(代码)

    Nginx配置文件里放入这段代码 server { location / { index index.php index.html index.htm l.php; autoindex on; if ...

随机推荐

  1. 什么是TensorFlow Serving

    答:1. 从Serving 可以看出,与服务有关; 2. 那么为啥还有TensorFlow的前缀?肯定与TensorFlow有着很大的关系: 3. 那么Tensorflow是用来干什么的呢?Tenso ...

  2. When should I use OWIN Katana?

    When should I use OWIN Katana? 解答1 In asp.net WebApi v2, the OWIN pipeline becomes the default. It i ...

  3. MSBI

    https://blog.csdn.net/fanyingnedu/article/details/78597207 Familiarity with Microsoft BI Stack - SSI ...

  4. Tensorflow一些常用基本概念与函数(三)

    摘要:本系列主要对tf的一些常用概念与方法进行描述.本文主要针对tensorflow的数据IO.图的运行等相关函数进行讲解.为‘Tensorflow一些常用基本概念与函数’系列之三. 1.序言 本文所 ...

  5. Missing artifact com.github.pagehelper:pagehelper:jar:3.4.2-fix的解决方法

    使用pagehelper.3.4.2.jar时报错,应该是无法从网络上下载该jar. 我的解决方案是: 从网络上下载一个pagehelper.3.4.2.jar包,然后复制到.m2目录中 如我的目录是 ...

  6. 人工神经网络 Artificial Neural Network

    2017-12-18 23:42:33 一.什么是深度学习 深度学习(deep neural network)是机器学习的分支,是一种试图使用包含复杂结构或由多重非线性变换构成的多个处理层对数据进行高 ...

  7. Redis高级命令操作大全--推荐

    redis安装和使用 redis安装 wget http://download.redis.io/redis-stable.tar.gz tar zxvf redis-stable.tar.gz cd ...

  8. Numpy np.array 相关常用操作

    https://www.cnblogs.com/oftenlin/p/7856389.html

  9. .Net Core中使用UEditor

    一.下载解压UEditor的.net版本(这个直接使用的话是asp.net的版本) 我下载的是这个 再给留上地址http://ueditor.baidu.com/website/download.ht ...

  10. 如果从excel表中导出insert-sql

    =CONCATENATE("INSERT INTO p_act_lottery(actId,status,grantWay,createTime,invalidTime,amount,pri ...