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

6
  • Is mod_rewrite installed and enabled in Apache? Also, try changing on to On Commented Feb 1, 2017 at 5:53
  • 1
    Possible duplicate of Codeigniter URL rewrite to remove index.php Commented Feb 1, 2017 at 5:55
  • @Magnus Eriksson how can I see mod_rewrite is enabled or not ? Commented Feb 1, 2017 at 6:21
  • What OS are you using? Btw, are you on PHP 5.3? You should really upgrade your system. 5.3 hasn't been supported for a long time. Even 5.6 has reach end of active support. Commented Feb 1, 2017 at 6:23
  • my php version is 5.5.38 Commented Feb 1, 2017 at 6:56

3 Answers 3

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>
Sign up to request clarification or add additional context in comments.

Comments

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.

Comments

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.

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.