mod_rewrite not working in controller subfolder CodeIgniter

Operating System:

  • Ubuntu

Software Used:

  • CodeIgniter 3.1.11
  • PHP 7.4.3
  • Apache 2.4 with mod_rewrite enabled

Known:

  • My controller is inside the Oauth2 folder
  • I have implemented .htaccess file as mentioned at CodeIgniter UserGuide

Wanted:

I want to remove index.php from the URL

Problem:

When i accessing http://localhost/Oauth2/Authorize then this cause an error, but when i access http://localhost/index.php/Oauth2/Authorize then its working

Question:

How to make mod_rewrite working inside controller subfolder

Answer:

Open /etc/apache2/sites-available/000-default.conf and add this code

<Directory /var/www/html>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>

Then restart apache service

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *