zoukankan      html  css  js  c++  java
  • CI 去 index.php

    简介:这是CI 去 index.php 的详细页面,介绍了和php,有关的知识、技巧、经验,和一些php源码等。

    class='pingjiaF' frameborder='0' src='http://biancheng.dnbcw.info/pingjia.php?id=339584' scrolling='no'>

    CI默认的rewrite url中是类似这样的,例如你的CI根目录是在/CodeIgniter/下,你的下面的二级url就类似这样http://localhost /CodeIgniter/index.php/welcome。不太好看,怎么把其中的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手册上也有介绍):

    1 RewriteEngine on
    2 RewriteCond $1 !^(index\.php|images|robots\.txt)
    3 RewriteRule ^(.*)$ /index.php/$1 [L]

    如果文件不是在www的根目录下,例如我的是:http://www.nowamagic.net/CodeIgniter/,第三行需要改写为RewriteRule ^(.*)$ /CodeIgniter/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'] = ""; 。

    view source print ?
    01 /*
    02 |--------------------------------------------------------------------------
    03 | Index File
    04 |--------------------------------------------------------------------------
    05 |
    06 | Typically this will be your index.php file, unless you've renamed it to
    07 | something else. If you are using mod_rewrite to remove the page set this
    08 | variable so that it is blank.
    09 |
    10 */
    11 $config [ 'index_page' ] = '' ;

    ok,完成。还要记得重启apache

    就这么简单,好好体验CI吧~

    爱J2EE关注Java迈克尔杰克逊视频站JSON在线工具

    http://biancheng.dnbcw.info/php/339584.html pageNo:8
  • 相关阅读:
    转 博客园 各种大牛合集
    系统学习qsort1 尤其partition
    转 大整数乘法 1 复杂度分析
    【转】如何设计一个LRU Cache?
    转微软大牛 13道链表操作
    框架设计之旅(1)--数据的分层
    框架设计之旅(2)--数据分层之实际应用
    DB2相关问题及解决方法:
    框架设计之旅--启航篇
    如何挑选水货诺基亚手机
  • 原文地址:https://www.cnblogs.com/ooooo/p/2246157.html
Copyright © 2011-2022 走看看