1

Removing index.php in CodeIgniter using .htaccess file is not working for me. I Tried following code eventhough not working.

    <IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L,QSA]
</IfModule>

I tried this http://firstcode.info/codeigniter-removing-index-php-from-url/. But not working.But its working in my localhost. I also edited httpd.config file.But off no use. Please help me.

3
  • Found this, github.com/riwakawebsitedesigns/htaccess_for_codeigniter may be use full has different htaccess for you to try out. Commented May 16, 2015 at 6:59
  • Thankyou I got Solution Commented May 16, 2015 at 7:05
  • Until you learn reading apache files, google for "far in space codeigniter htaccess". Most useful example you could need and best one I've found so far. Commented May 16, 2015 at 11:10

5 Answers 5

1

Your mentioned code is correct.

You have to modify apache2.conf (/etc/apache2/apache2.conf --- its my servers path) check your path.

Find this culprit "AllowOverride None" and /var/www/ or /var/www/html

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

update to

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

Dont forget to sudo service apache2 restart

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

2 Comments

/var/www/ also important. This path to your working directory should be correct
Thank you for response I got it fixed
1

STEP 1

Open the folder “application/config” and open the file “config.php“. find and replace the below code in config.php file.

find the below code

$config['index_page'] = "index.php"

replace with the below code

$config['index_page'] = "

STEP 2

Write below code in .htaccess file

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

STEP 3

“application/config/config.php“, then find and replace the below code

find the below code

$config['uri_protocol'] = "AUTO"

replace with the below code

$config['uri_protocol'] = "REQUEST_URI" 

2 Comments

I already tried the above code I am getting Internal Server Error
Thank you for response I got it fixed
0

Try this code

<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,
    RewriteCond %{REQUEST_URI} ^system.*
    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>

In my config.php file ihave following settings.

$config['index_page']   = "";
$config['uri_protocol'] = "PATH_INFO";

1 Comment

Thank you for response I got it fixed
0

Please try change base url as well in config.php, If using localhost or domainname.com

$config['base_url'] = 'http://localhost/'; // localhost

OR

$config['base_url'] = 'http://domainname.com/'; // domainname.com

Comments

0

add in .htacess

RewriteEngine on
RewriteCond $1 !^(index\.php|public|\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$

remove "index.php" from $config['index_page'] in config.php (keep blank value)

and fix the permission of project folder.

Comments

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.