Welcome Guest, Not a member yet? Register   Sign In
Need help setting up CodeIgniter with MAMP environment
#1

[eluser]steven1454[/eluser]
Hi,

I'm trying to setup CodeIgniter to use MAMP as a development environment but I'm running into some problem with the URI resolving, I've already spent 7 hours googling and reading CI manual again and again, nothing even close to the problem I'm facing.

I configured MAMP to use
Code:
/Users/steven/Sites
besides that everything in MAMP is default setting.

My CodeIgniter location is
Code:
/Users/steven/Sites/project1/

I have no problem accessing CodeIgniter's default welcome page using this address:
Code:
http://localhost:8888/project1/

However, if I try to access it this way, Apache will throw a page not found error
Code:
http://localhost:8888/project1/controllerName/methodName

But if I manually force the index.php part into it, everything is fine again.
Code:
http://localhost:8888/project1/index.php/controllerName/methodName


I thought this has something to do with the .htaccess file, after hours of googling and researching, I found that most people were using the .htaccess for the purpose of removing the index.php from the URL, but in my case, when I access http://localhost:8888/project1/, there is no index.php there in the first place, and I think all I'm trying to accomplish is to redirect every request that can't be found back to index.php since that's how CI functions.

After some research, I created the htaccess file below and placed that in
Code:
/Users/steven/Sites/project1/.htaccess

Code:
Options -Indexes
OPtions +FollowSymLinks
OPtions -MultiViews

DirectoryIndex index.php

<IfModule mod_rewrite.so>
  RewriteEngine on
  RewriteBase /project1/

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d

  RewriteRule ^(.*)$ project1/index.php/$1 [NC,L,QSA]
</IfModule>
<IfModule !mod_rewrite.so>
  ErrorDocument 404 index.php
</IfModule>

Now, if I just go to the root directory, CI will display correctly, however when I click on any links that attempt to call a controller and function using URI, it will load a page with the word "index.php" as the only page content, no any other html tags on the page.

I've experimented with the .htaccess file for hours already, adding question mark in
RewriteRule ^(.*)$ project1/index.php?/$1 [NC,L,QSA]
or place the .htaccess file under /Users/steven/Sites/

I couldn't think of any other reason why this won't work. and after hours of searching, I never manage to find one any one experiencing the same problem.

I'm in serious need of some guidance on this, thanks!
#2

[eluser]steven1454[/eluser]
Please ignore the question, I've found the answer. It's very embarrassing I didn't spot this earlier. It should have been <IfModule mod_rewrite.c> and not .so

I apologize for making a big deal out of this, moderators please feel free to delete this whole thread...




Theme © iAndrew 2016 - Forum software by © MyBB