0

I recently shifted from Windows to MAC (Catalina 10.15.4). I installed Xampp and clone my Codeigniter project into /htdocs. I want to fix index.php issue "Remove index.php from url", which most of you guys are familiar with. Can anyone know how to fix this in MAC ?

.htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

config.php

$config['base_url'] = 'http://localhost/Rsss';

$config['index_page'] = '';
8
  • This should help - stackoverflow.com/questions/12272731/…. Sounds like your mod-rewrite is not enabled Commented Apr 16, 2020 at 17:05
  • Are you now using PHP-FPM now you moved to the MAC? Commented Apr 16, 2020 at 17:09
  • Brother thanks for reaching out. I tried this. But it didn't work. Commented Apr 16, 2020 at 17:14
  • @RiggsFolly nope. Commented Apr 16, 2020 at 17:16
  • did you check this: stackoverflow.com/a/24255653/2275490 Commented Apr 16, 2020 at 17:31

1 Answer 1

1

Answering my own question. It's a proper solution but not for XAMPP users. Edit your /httpd.conf file using sudo nano ../../private/etc/apache2/httpd.conf and change all occurrence of

AllowOverride None

to

AllowOverride All

Also find this line

#LoadModule rewrite_module modules/mod_rewrite.so

and uncomment it.

LoadModule rewrite_module modules/mod_rewrite.so

My .htaccess in /Project directory. Not in /application

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

And edit your Codeigniter's project config.php file. Project/application/config/config.php and set

$config['sess_save_path'] = '/tmp';

Because while running this project through System's Apache it'll throw an error of session directory. By default, its value is NULL so don't forget to edit it. Your base_url should be

$config['base_url'] = 'http://localhost:8080';

You can use whatever port is free. This all must fix your index.php issue. Now configure your Mysqli db or whatever. You can use localhost/phpmyadmin for the DB but it'll make you dependent on Xampp. To overcome this, install Mysql library & MysqlWorkbench application. Start your mysql server using mysql.server start. Configure your database.php file and run your project using this command.

php -S localhost:8080

Run this command into your project directory. And yes it's better to move out your project from /htdocs to some other directory. (Out of xampp)

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.