Hello,
I am trying to get FuelPHP running on my mac. I am using OSX's web server sharing, which uses the Apache mod_userdir which basically maps "http://localhost/~jeff/" => "/Users/jeff/Sites/". Now, under my Sites folder I want to have multiple sites/apps that I can work on at the same time, so, ideally, what I want is
[url=http://localhost/~jeff/app1]http://localhost/~jeff/app1[/url] => /Users/jeff/Sites/app1
[url=http://localhost/~jeff/app2]http://localhost/~jeff/app2[/url] => /Users/jeff/Sites/app2
etc..
and each app folder would have it's own copy of FuelPHP, so app1 would look like:
/Users/jeff/Sites/app1/
.........fuel/
..................app/
..................core/
..................packages/
.........public/
..................assets/
I understand that this isn't secure, but this is just my development machine. I also understand that I need a special .htaccess file, but I've played around with it and I can't get anything to work correct. Does anyone know what the .htaccess file should look like, and where exactly I should put it?
You don't have to do it this way on your Mac.
Open Terminal and run
sudo nano /etc/apache2/extra/httpd-vhosts.conf
This will give you some examples of setting up folders anywhere on your Mac. For example:
<VirtualHost *:80>
DocumentRoot "/Users/thomas/Sites/fuelphpapp/public"
ServerName test.app.com
</VirtualHost>
Then you enable htaccess everywhere
Terminal:
sudo nano /etc/apache2/httpd.conf
Look for
<Directory />
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
Change to (note the third line)
<Directory />
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Thanks two both of you for your suggestions. However, I ended up "solving" this in my own way.
I had to edit the .htaccess under public as well as put another .htaccess file in the directory above.
/Users/jeff/Sites/app1/.htaccess
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /~jeff/app1/
RewriteRule ^(.*)$ public/index.php/$1 [L]
</IfModule>
/Users/jeff/Sites/app1/public/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /~jeff/app1/public/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Note the FollowSymLinks (which was causing 403 errors before I had that), the and RewriteBase in both. This seems to do the trick and hopefully its correct. I can access [url=http://localhost/~jeff/app1/welcome/index]http://localhost/~jeff/app1/welcome/index[/url] (or just [url=http://localhost/~jeff/app1/]http://localhost/~jeff/app1/[/url]) and it all works!
The quick fix: If public is not your docroot, but the parent folder is, simply move everything from the public folder to the parent, and delete the public folder.
If you're going to move this from development to a server that is properly configure, this might not be the best idea, you need an htaccess in the parent folder.
Copy the htaccess from public to the parent folder, and add a "Rewritebase /public" to it. That should do the trick.