Search code examples
php.htaccesscodeignitercodeigniter-4

While removing index.php from url in codeigniter, i am getting following error .Not Found The requested URL was not found on this server


While removing index.php from URL, I am getting an error Not found

From :- http://localhost/Inspire/index.php/welcome/dashboard

to this

http://localhost/Inspire/welcome/dashboard

.htaccess

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



config.php



$config['index_page'] = ''; 

Solution

  • Codeigniter 4 have two different .htaccess files, you need to change the one in public folder:

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