0

I've looked at many articles and tried different ways but it still doesn't work.

Now my URLs look like mysite.com/index.php/[controller]. The goal is mysite.com/[controller].

In config.php:

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

My .htaccess file contains

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

Also mod_rewrite is enabled in my Apache server.

Any other solutions?

Abdulla Nilam
  • 36,589
  • 17
  • 64
  • 85

5 Answers5

1

In application/config/config.php

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

in .htaccess (Place Outside application folder)

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

Update 2018-02-27

$config['base_url'] = 'https://stackoverflow.com/'; # Must fill

else you get this error Codeigniter echoing [::1] instead of localhost

use this .htaccess

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

Refference

Abdulla Nilam
  • 36,589
  • 17
  • 64
  • 85
0

try this in your config file

$config['base_url'] = '';
$config['server_root'] = $_SERVER['DOCUMENT_ROOT'];
Circleshair
  • 146
  • 4
0

This one is working fine for me, you can try with this

Options +FollowSymLinks 
RewriteEngine on 
RewriteCond $1 !^(index\.php|resources|robots\.txt) 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
Suvash sarker
  • 3,140
  • 1
  • 18
  • 21
0

This works for me [in linux operating system]:

<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteBase /
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
Al Amin Chayan
  • 2,460
  • 4
  • 23
  • 41
0

in config file use your project url in base_url

$config['base_url'] = 'http://localhost/project';
Imtiaz Pabel
  • 5,307
  • 1
  • 19
  • 24