0
votes

I've been out of the CodeIgniter game for a bit and I just set up an environment with MAMP and CodeIgniter. I cannot seem to get any custom route to work.

For example. If I edit the config.php file to add, say...

$route['poo'] = 'poo';

It does not work. Even if I try absolutely referencing "localhost/Welcome" I get nothing

I downloaded the .htaccess file from gitHub. Did not work. I looked elsewhere on the internet and tried the following...

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

Does not work.

I tried a blank .htaccess file. Does not work.

To clarify. If I change... $route['default_controller'] = 'poo';

It does work. But anything beyond "default_controller" does not

I love using CodeIgniter but I find it frustrating that it takes so much time just to get simple routing to work properly.

Environment is MAMP running on OS High Sierra as localhost on port 80.

Any help would be appreciated.

1

1 Answers

1
votes

I answered my own question.

For anyone with the same issue,

You have to first create a new .htaccess file in the root folder of CodeIgniter

then add the following lines.

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

So simple yet so hard to find.