Fixing CodeIgniter and .htaccess issues on Leopard


This is my first post and I’ll try to show you guys a few configurations regarding CodeIgniter with Leopard. First I was having problems with .htaccess and mode_rewrite, to remove de “index.php”. Searching CodeIgniter forums, many many people had same problem, 500 Internal Erros, 403 Forbidden and so on. I was almost givin up, when I tried working with Virtual Hosts on apache, witch is the best and the correct solution in my case, because I develop many sites. Well, just for the record, I’m not using pack solutions, like, just de built-in apache+php5, and installed mysql.

I’ll show you how i solved my problem using Virtual Hosts. You have to edit the following files:


I used textmate, using terminal, type sudo mate . If you dont have textmate, use sudo open . It will open the default texteditor of MacOSx. Put your password and here we go:

hosts file:
[cc lang=”xml”]
# Host Database
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
## localhost # Site no.1 # Site no.2. # Here you can add as many lines (sites) you develop. broadcasthost
::1 localhost
fe80::1%lo0 localhost

You don’t have to reboot the system or apache. In this example, if you type in safari “”, you will be forward to the site configured in Virtual Hosts, even if “” exists on internet.

httpd file:
this is a long file, so I’ll show a few parts. On my config, I commented the following line, I don’t have many users on my macbook, I only have my own user, so I don’t need this module to be loaded:

[cc lang=”xml”]
#LoadModule userdir_module libexec/apache2/

This is very very important to be sure these line are uncommented:

[cc lang=”xml”]
LoadModule rewrite_module libexec/apache2/


[cc lang=”xml”]
# Virtual hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf

I don’t think you need to edit any thing more on this file. The last and more importante file is where you will setup avery website you develop.

httpd-vhosts file:

Do not touch this line:

[cc lang=”xml”]
NameVirtualHost *:80

Here is the root of your sites

[cc lang=”xml”]

DocumentRoot “/Users//Sites”
ServerName localhost


And here your Virtual Hosts:

[cc lang=”xml”]

DocumentRoot “/Users//Sites/
AllowOverride All
Options +FollowSymLinks
Order allow,deny
Allow from All


The following lines allow me to use the functions of .htaccess to remove the index.php, and fix the 403 forbidden problems.

[cc lang=”xml”]
AllowOverride All
Options +FollowSymLinks

When I was not using virtual hosts, I configured the single webserver on apache, and used something like that:

I had 500 Internal Server problems, and I’m almost sure it’s because the “root” of my “website1″ not being the actual root of my webserver.

Here is my .htaccess config:

[cc lang=”xml”]
RewriteEngine on
RewriteBase /
# Hide the application and system directories by redirecting the request to index.php
RewriteRule ^(application|system|\.svn) index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [QSA,L]

So, I hope a could help anyone having the same problems I had. This mini-tutorial was tested on Mac OS X 10.5.2, and I think it might work on windows and linux too, because it’s more apache stuff.

Did you like this? Share it:

So, what do you think ?