1

I am trying to remove index.php from URL, but I keep getting error 404. Config file:

$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';

This is my .htaccess file:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
4
  • Try with RewriteRule ^(.*)$ index.php/?$1 [L] - change last line and try. Commented Jul 16, 2017 at 22:54
  • 3
    Just a tip in codeigniter 3 and up versions you must set your base url. Commented Jul 16, 2017 at 23:43
  • See this helper link may it helps Link Commented Jul 17, 2017 at 3:27
  • Is your install on a lampp/xampp or on a live server? Commented Jul 17, 2017 at 12:51

3 Answers 3

2

You need one more .htaccess file in your application folder, and here is the detail of the file:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|captcha|css|js|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
Sign up to request clarification or add additional context in comments.

Comments

1

Please copy and paste following code in your htaccess file and put it in root folder and application folder

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

Comments

0

Open config.php and do following replaces

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

to

$config['index_page'] = ""

Just replace

$config['uri_protocol'] ="AUTO"

to

$config['uri_protocol'] = "REQUEST_URI"

AND IN HTACCESS FILE put following code

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

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.