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

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

问题描述

我试过谷歌上的一切与删除index.php从codeigniter中的URL,但没有解决方案为我工作
我使用codeigniter版本2.1.0
如何从我的URL删除索引? / p>

感谢

解决方案

.php 确保

  $ config ['index_page'] =; 

然后设置为 .htaccess

 < IfModule mod_rewrite.c> 
RewriteEngine On
RewriteBase /

#Removes用户访问系统文件夹。
#另外,这将允许您创建一个System.php控制器,
#previously这是不可能的。
#'system'可以替换,如果你已经重命名您的系统文件夹。
RewriteCond%{REQUEST_URI} ^ system。*
RewriteRule ^(。*)$ /index.php?/$1 [L]

#当您的应用程序文件夹不是在系统文件夹
#此代码段阻止用户访问应用程序文件夹
#提交者:Fabdrol
#Rename'application'到您的应用程序文件夹名称。
RewriteCond%{REQUEST_URI} ^ application。*
RewriteRule ^(。*)$ /index.php?/$1 [L]

#检查用户是否试图访问一个有效的文件
#s如一个图像或CSS文档,如果这不是真的,它发送
#request到index.php
RewriteCond%{REQUEST_FILENAME}! - f
RewriteCond%{REQUEST_FILENAME}!-d
RewriteRule ^(。*)$ index.php?/ $ 1 [L]
< / IfModule>

< IfModule!mod_rewrite.c>
#如果我们没有安装mod_rewrite,所有404的
#都可以发送到index.php,一切正常。
#提交者:ElliotHaughin

ErrorDocument 404 /index.php
< / IfModule>

您已经准备好了!


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 ?

Thanks

解决方案

In application/config.php make sure that

$config['index_page'] = "";

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> 

You're all set!

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

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