0

I have a project in CodeIgniter that I am running on my local machine on LocalHost. I have to use http://localhost/projectname/index.php/controller/function to run my APIs. I want to access the same URL but without including index.php in the URL.

Earlier I had XAMPP installed and I was using its htdocs folder and everything was functioning as required. But now I have uninstalled it and manually set up Apache 2.4, PHP 8, and MySQL 8. After doing so, there is this issue.

I am new to both manually setting up servers and CodeIgniter. Please help me fix this and if possible give a reason why this happens, it will help me learn.

7
  • 1
    Does this answer your question? How to remove "index.php" in codeigniter's path Commented Jul 30, 2021 at 7:10
  • @brombeer I have tried this solution but it is not working Commented Jul 30, 2021 at 7:13
  • Is mod_rewrite installed and enabled in your Apache? Is .htaccess allowed? Commented Jul 30, 2021 at 7:16
  • @brombeer I know nothing about it. Maybe that's the issue. How to do it? Commented Jul 30, 2021 at 7:18
  • Have you searched this site already? Pretty sure there are answers on the topic Commented Jul 30, 2021 at 7:25

1 Answer 1

2

Add a .htaccess in the root directory and then add the following rules to the .htaccess file

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

Then find the following file in your application. File Path is application/config/config.php. In this file find below the code

$config['index_page'] = 'index.php';

Change that line as below.

$config['index_page'] = '';

Now try to open URLs without index.php.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.