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.

13

5 Answers 5

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.

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

Comments

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>

Comments

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';

Comments

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.

Comments

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"

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.