Archive for the ‘Laravel’ Category

Laravel .htaccess localhost MAMP and Mac OS X

I was, like anyone, excited about the release of Laravel 4 and quickly set about following the initial installation instructions on a vanilla vhost locally to have a play around with. I quickly found that the default suggested .htaccess file was causing a server error in MAMP on OS X.

I got around it with a little trial and error and can confirm the below contents in your .htaccess file – works great for me.

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /index.php [L]

The offending line from the suggested .htaccess contents was

RewriteRule ^ index.php [L]

Laravel and WordPress as a subfolder

I wanted to recreate a small blog for a site I was building in Laravel for a bit of fun but didn’t want to waste/spend loads of time recreating a blog. When in my honest opinion WordPress does an un-touchably good job of that already.

If you want to just simply install WordPress in your Laravel install under a subfolder, it’s quite simple really. Just install into public/blog (or whatever you want to name your blog).

Mac terminal fan? Little SVN one liner for you.

cd public | mkdir blog && cd blog | svn co http://core.svn.wordpress.org/tags/3.5 .

If you don’t use the public folder as your vhosts root like me you could use a .htaccess rule instead.

# Apache configuration file
# http://httpd.apache.org/docs/2.2/mod/quickreference.html
# Note: ".htaccess" files are an overhead for each request. This logic should
# be placed in your Apache config whenever possible.
# http://httpd.apache.org/docs/2.2/howto/htaccess.html
# Turning on the rewrite engine is necessary for the following rules and
# features. "+FollowSymLinks" must be enabled for this to work symbolically.
<IfModule mod_rewrite.c>
	Options +FollowSymLinks
	RewriteEngine On
</IfModule>
# For all files not found in the file system, reroute the request to the
# "index.php" front controller, keeping the query string intact
<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^public
    RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

Maybe something like that might help? But don’t hold me to it. You could also use a exclusion rule in your .htaccess file.

RewriteCond %{REQUEST_URI} !^/(~blog|/.*)$