3

I am new in codeigniter and i am trying to remove index.php from URL in Codeigniter but not able to do this. I wrote code in my .htaccess file-

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

My Apache mod_rewrite is enable.

But still got 404 error when i am trying to access any controller without using index.php.

Please help.

Thanks.

6
  • have you enabled mod rewrite module. you have remove index.php in config.php file Commented Mar 23, 2015 at 8:05
  • yes . i have already mention this in my question and i have already removed index.php form config file. Commented Mar 23, 2015 at 8:06
  • stackoverflow.com/questions/19183311/… duplicate Commented Mar 23, 2015 at 8:07
  • 1
    i did every thing which are suggested in above Ref . but still facing same problem. Commented Mar 23, 2015 at 8:13
  • Sometimes, and that is depending on server (GoDaddy for example), you need to append question mark after index.php. I.e. RewriteRule ^(.*)$ /index.php?/$1 [L]. Also google for far in space codeigniter htaccess and try to use code provided. Commented Mar 23, 2015 at 8:41

3 Answers 3

1
<IfModule mod_rewrite.c>
    RewriteEngine on 
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/index/?$ $1 [L,R=301]
</IfModule>

Is the code I'm using, it works on every hosting platform I've used it on.

Sign up to request clarification or add additional context in comments.

2 Comments

Also application/config/config.php - change $config['index_page'] = 'index.php'; to $config['index_page'] = '';
@BushraShahid wat error are you getting implementing this answer
1

This should help you,

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php/$1 [L,QSA]

Comments

0

check this code of htaccess file.

DirectoryIndex index.php    
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|public|images|css|js|robots\.txt)    
RewriteRule ^(.*)$ index.php?/$1 [L]

you can find your answer refference here

My .htaccess file is not working

moreover can you share your base url with us? as this error may be due to wrong baseurl set.

1 Comment

@Bushra kindly note ? sign after index.php

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.