2016-02-05 03:50
浏览 235


I know this question has been asked a number of times. However, I still wasn't able to get rid of index.php url. It is preventing me to access my controller directly.

I am current using CodeIgniter 2.2.2.
And the following is my .htaccess file:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]


//  Find the below code

$config['uri_protocol'] = "AUTO"

//  Replace it as

$config['uri_protocol'] = "REQUEST_URI" 

Any Idea? Thanks in advance for your time.

图片转代码服务由CSDN问答提供 功能建议

我知道这个问题已被多次询问。 但是,我仍然无法摆脱 index.php网址。 它阻止我直接访问我的控制器。

我目前正在使用 CodeIgniter 2.2.2
以下是我的。 htaccess 文件:

 &lt; IfModule mod_rewrite.c&gt; 
RewriteEngine On 
RewriteCond%{REQUEST_FILENAME}!-d \  nRewriteRule ^(。*)$ index.php / $ 1 [L] 
&lt; / IfModule&gt; 

application / config: < / p>

 $ config ['uri_protocol'] =“AUTO”
 $ config [  'uri_protocol'] =“REQUEST_URI”

任何想法? 提前感谢您的时间。

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

8条回答 默认 最新

  • dongxin8392 2016-02-15 07:54

    Finally fixed my problem. I would like to share my answer to all of you. I am currently using a mac, my rename my .htaccess file into htaccess.txt And had the following code inside htaccess: RewriteEngine On

    #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 %{ENV:REDIRECT_STATUS} ^$
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
    <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

    Then make sure Apache is reading the htaccess.txt file by doing this:

    1. Uncomment the following line on your httpd.conf

    2. Go inside to the extra/httpd-default.conf file and change this line of code: AccessFileName .htaccess to AccessFileName htaccess.txt

    3. Restart Apache server

    4. Inside your config, make sure to leave 'base_url' empty (index page can still be there, doesn't matter). And $config['uri_protocol'] = 'REQUEST_URI';

    Hope this can help others out there!

    解决 无用
    打赏 举报

相关推荐 更多相似问题