1

I would like to remove index.php by using .htaccess file in root directory.

my framwork is codeigniter .

my htaccess :

AddType application/x-httpd-php53 php53 php

php_flag  log_errors on
php_flag  display_errors on
#php_value error_reporting 8
php_value error_reporting E_ALL

<IfModule mod_rewrite.c>

RewriteEngine on
RewriteCond %{HTTP_HOST} ^megarooz.com/$ [NC]
RewriteRule ^(.*)$ http://megarooz.com/$1 [R=301,L]

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

order allow,deny
allow from all

my config:

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


$config['index_page'] = '';

I got this message :

Not Found
The requested document was not found on this server. 

It doesnt work :

http://megarooz.com/admin/Admin/login

It works fine :

http://megarooz.com/index.php/admin/Admin/login

F.Joodaki
  • 141
  • 3
  • 16

3 Answers3

0

Try doing using below code

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L] // you have added / before index.php
    </IfModule>
Nishant Nair
  • 1,999
  • 1
  • 13
  • 18
0

Try like this....

1.In your root folder. .htaccess file

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

2.In application/config/config.php set following things

$config['base_url'] = 'http://megarooz.com/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';

Hope it works.

Hikmat Sijapati
  • 6,869
  • 1
  • 9
  • 19
0

As this is an extremely commonly asked question on Stack I'd like you to some more research next time as it's filled with CI's index.php questions. Non the less I do agree with CI's htaccess being a little bad as it hasn't always worked for me either, what I end up doing is grabbing the htaccess from Laravel.

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

Never had problems with it, hope this will work.

killstreet
  • 1,251
  • 2
  • 15
  • 37