删除 codeigniter 2.1.0 中的 index.php [英] Remove index.php in codeigniter 2.1.0

查看:26
本文介绍了删除 codeigniter 2.1.0 中的 index.php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 google 上尝试了与从 codeigniter 中的 URL 中删除 index.php 相关的所有内容,但没有解决方案对我有用我正在使用 codeigniter 版本 2.1.0如何从我的 URL 中删除索引?

I tried everything on google related to removing index.php from URL in codeigniter but no solution worked for me I am using codeigniter version 2.1.0 How I can remove index form my URL ?

谢谢

推荐答案

application/config.php 中确保

$config['index_page'] = "";

然后将其设置为您的 .htaccess 文件:

Then set this as your .htaccess file:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule> 

你已经准备好了!

这篇关于删除 codeigniter 2.1.0 中的 index.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆