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]
2
Answers
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
and the file somewhere around line 251 to 278 change
AllowOverride
toAll
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 inAnd the
.htaccess
file contains the following:If still it doesn't work, find all
AllowOverride None
inhttpd.conf
and change them toAllowOverride All
. Restart your computer if necessary.In
C:laragonetcapache2sites-enabled
you are going to find all the v-hosts of laragon you have in your working directory.When you find the codeigniter one and you open to edit it you are going to see a normal apache
VirtualHost
.Change this line:
<Directory "C:/workspace/my_project">
to :
<Directory "C:/workspace/my_project/index.html">
Rename the laragon .conf file and remove
auto.
from the file name.Restart everything.
careful to open the right v-host. Laragon creates 2 v-hosts, 1 with your extension defined in settings and one with .com extension.
Edit: