0

I know this question is asked many times before and I've gone through most of them already but couldn't find a solution. I've tried most of the answers given here, here and in CodeIgniter official documentation. And restarted apache each time. It didn't work for me. mod_rewrite is already enabled in my apache server.

Weird thing is, I've a working example for WAMP (in my laptop):

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

<IfModule !mod_rewrite.c>
ErrorDocument 404 /project/index.php
</IfModule>

It works perfectly in WAMP, but it doesn't work in LAMP. Any kind of help is appreciated.

Community
  • 1
  • 1
Anoop S
  • 33
  • 2
  • 6

5 Answers5

0

Please use below code:

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)

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

I have used this and it is working.

Kamlesh
  • 654
  • 8
  • 21
0

Try Below code in your .htaccess file

  <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /ROOT DIRECTORY NAME/

    # Directs all EE web requests through the site index file
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

<Directory "/path/to/document/root/">
  AllowOverride All
  Allow from All
</Directory>
Sujal Patel
  • 592
  • 2
  • 5
  • 14
0

Just like this......

.htaccess inyour root directory with following code..

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

Set configuration in application/config.php as follows..

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

$config['index_page'] = '';

$config['uri_protocol'] = 'REQUEST_URI';
Hikmat Sijapati
  • 6,869
  • 1
  • 9
  • 19
0

I made it working with the help of following .htaccess code:

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

And I updated <Directory /var/www/> section of /etc/apache2/apache2.conf file with:

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

It solved all problems and now it works fine.

Anoop S
  • 33
  • 2
  • 6
0

here it is my approach:

RewriteEngine on 
RewriteBase /

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

And also in config.php replaces

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

to

$config['index_page'] = ""

and also in the same file replace

$config['uri_protocol'] ="AUTO"

by

$config['uri_protocol'] = "REQUEST_URI"
Yahya
  • 706
  • 8
  • 23