0

I'm using CodeIgniter v.3.0.4 and I'm unable to remove the 'index.php' from URL.

  1. I've added the .htaccess file:

    <ifmodule mod_rewrite.c="">
    RewriteEngine On
    RewriteBase /project_01/
    
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]
    
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
    </ifmodule>
    <ifmodule !mod_rewrite.c="">
    
    ErrorDocument 404 /index.php
    </ifmodule>
    
  2. In application folder > config.php > I edited the value to:

    $config['index_page'] = '';
    

    And:

    $config['uri_protocol']= 'REQUEST_URI';
    

    And:

    $config['base_url'] = 'http://localhost/Project_01/';
    
  3. I checked that my Apache server conf file does not have the pound sign next to the line:

    LoadModule rewrite_module modules/mod_rewrite.so
    

What am I doing wrong? Or what am I not doing?

It worked fine in prior versions of CI, what changed?

3
  • can you give an example URL and what it should be rewritten to? Commented Feb 24, 2016 at 1:28
  • instead of the CI default structure "localhost/Project_01/index.php/about" I wanna make it a clean URL, without the 'index.php' like so: "localhost/Project_01/about" Commented Feb 24, 2016 at 1:37
  • The Rewrite seems ok as long as its in /Project_01/.htaccess. what's the problem you're seeing when you request localhost/Project_01/about ? Commented Feb 24, 2016 at 5:32

1 Answer 1

1

Because your rule is sending the request to the query string, you need to use QUERY_STRING for the uri_protocol, and not REQUEST_URI.

As an alternative, and if you would like to keep REQUEST URI, you can change the rule to either one of the following:

RewriteRule ^(.*)$ index.php/$1 [L]
RewriteRule ^ index.php [L]
Sign up to request clarification or add additional context in comments.

1 Comment

I changed the rule to: RewriteRule ^(.*)$ index.php/$1 [L] . And still I get 404 - The requested URL /Project_01/gallery/ was not found on this server. dont know what am I not doing... all of the code can be downloaded from: github.com/Revitalizm/Project_01 . Please advise.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.