I want to remove the index.php
from URL in CodeIgniter while using Laragon
I have edited the .htaccess
file in CodeIgniter and applied a rule; I also changed the index_page
variable to empty string in application/config/config.php
.
It, as expected, works completely fine in a web environment setup using WampServer/xampserver
but fails when using Laragon
.
The problem may be with the Laragon environment but I don’t know how to fix it.
How can I make it work in a Laragon environment
? (As Working in Wampserver).
My .htaccess
file contains the following code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /myFolder/index.php/$1 [L]
I solved the problem then by getting some help on Laragon community
The fix is actually simple.
Laragon is compiled with its httpd.conf
set to reject overwrite on the document root.
To edit this, check the file on
{LARAGON_ROOT}/bin/apache/httpd{other-version-details}/conf/httpd.conf
and the file somewhere around line 251 to 278 change AllowOverride
to All
and restart your Laragon Server.
That fixes it
NOTE:
You have to do settings in your codeIgniter, like your index_page
variable should be empty in
application/config/config.php
$config['index_page'] = "";
And the .htaccess
file contains the following:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /yourFolderName/index.php/$1 [L]
If still it doesn't work, find all AllowOverride None
in httpd.conf
and change them to AllowOverride All
. Restart your computer if necessary.