您好,欢迎来到学习哇。
搜索
您的当前位置:首页ci框架如何隐藏index.php

ci框架如何隐藏index.php

来源:学习哇


ci框架隐藏index.php的方法:首先修改apache配置文件;然后创建htaccess文件;接着修改Ci配置文件;最后重启apache即可。

推荐:《PHP视频教程》

1. 修改 apache 配置文件

  • 开启重写模块 conf/httpd.conf
  • 去掉前面的#
    LoadModule rewrite_module modules/mod_rewrite.so

    对于Ubuntu,需要在apache安装目录下的 mods-enabled 文件夹中创建软连接。

    进入 /mods-enabled 下,

     -s ../mods-available/rewrite.load rewrite.load # 要确保 ../mods-available/rewrite.load 文件存在,不存在需要安装rewrite模块

    注:apache安装目录下:mods-available---未启用的模块,mods-enabled----已启用的模块

  • AllowOverride None 修改为 AllowOverride All
  • 可以在apache的配置文件 conf/httpd.conf 末尾添加如下代码,或是在 sites-enabled 文件夹下新建个 .conf 文件,文件名随意,也可像 mods-enabled/ 下那样创建链接。

    Alias /athena "/home/liuqian/workspace/athena/" # 依据实际情况改为自己的路径<Directory "/home/liuqian/workspace/athena/"> # 依据实际情况改为自己的路径
     Options Indexes MultiViews FollowSymLinks AllowOverride All # 主要是这个
     Order allow,deny
     Allow from all</Directory>

    注:apache安装目录下:sites-available---未加载的配置文件,sites-enabled----已加载的配置文件

    2. 添加 .htaccess 文件

    进入到项目文件夹下,在 index.php 所在的目录下创建 .htaccess 文件

    文件中写如下:

    /%{REQUEST_FILENAME} !-%{REQUEST_FILENAME} !- !^(index.php| index.php

    3. 修改Ci配置文件 application/config/config.php

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

    改为:

    $config['index_page'] = "";

    4. 重启apache 就ok了。

    sudo apachectl restart # 这里是ubuntu的重启命令

    Copyright © 2019- xuexiwa.cn 版权所有

    违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

    本站由北京市万商天勤律师事务所王兴未律师提供法律服务