1

I have tried all the possible solutions that I found here in similar questions but with no luck!

I just want to remove the index.php from the URI.

I am using Codeigniter 3, on macOS High Sierra and MAMP PRO 5.2.

In the .htaccess file which is located inside application folder (root) I have the following code:

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

I have also tried

RewriteRule ^(.*)$ index.php?/$1 [L]

After that I have tried the followings in the config.php file:

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

or

$config['base_url'] = 'http://'.$_SERVER['HTTP_HOST'].'/';

and also

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

or

$config['index_page'] = '';

I am not sure if I am missing something or the issue is with my Apache server.

Don't Panic
  • 13,965
  • 5
  • 32
  • 51
chrysst
  • 347
  • 1
  • 6
  • 22
  • `.htaccess` should not be in in your `application folder (root)`. It should be in `public_html/`, where `index.php` is. – Don't Panic Feb 10 '19 at 10:02
  • @Don'tPanic You are right! Thank you! If you want you can create an answer explaining this! Cheers, – chrysst Feb 10 '19 at 11:58

3 Answers3

2

.htaccess should not be in in application folder (root) but it should be in public_html/, where index.php is.

chrysst
  • 347
  • 1
  • 6
  • 22
0

I'm assuming that everything is ok with mamp out of the box, so lets say its a codeigniter's configuration problem.

First of all .htaccess file is located in FCPATH beside index.php file and the first four lines from the docs works just fine.

Secondly, you need to set you base_url in config.php manually till the path of you FCPATH again the path of your index.php.

Thirdly, but not needed actually, remove index_page value in config.php.

Supposingly you did all of that already, then you need to check your mamp configuration cause its not codeigniter's problem then.

You got to enable mod_rewrite in apache.

Sherif Salah
  • 2,085
  • 2
  • 9
  • 21
0

Edit the https.conf file, like with any Apache server. This is the best way to edit settings like this. The file is located at ~/Applications/conf/apache/https.conf

Bilaal Rashid
  • 828
  • 2
  • 13
  • 21