skip to Main Content

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


  1. Chosen as BEST ANSWER

    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.


  2. 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:

    <VirtualHost *:80> 
        DocumentRoot "C:/laragon/www/gmap_polygons/application/""
        ServerName gmap_polygons.dev 
        ServerAlias *.gmap_polygons.dev 
        <Directory "C:/workspace/woo-backend-laravel/application/">
            AllowOverride All
            Require all granted
        </Directory>
    </VirtualHost>
    
    # If you want to use SSL, enable it by going to Menu > Apache > SSL > Enabled
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search