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.

2
  • .htaccess should not be in in your application folder (root). It should be in public_html/, where index.php is. Commented Feb 10, 2019 at 10:02
  • @Don'tPanic You are right! Thank you! If you want you can create an answer explaining this! Cheers, Commented Feb 10, 2019 at 11:58

3 Answers 3

2

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

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

Comments

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.

3 Comments

how to enable the mod_rewrite? I tried to work with terminal but do not allow me to use sudo command!
@chrysst have a look at this and let me know.
Finally the issue was the location of the .htaccess file.. thank you for your help!
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

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.