Htaccess redirect for Laravel 4

Needed to redirect all non-www to www domain (for Google SEO purpose) but was having problem with the routing in Laravel.

Found this to work perfectly.

<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On

RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

</IfModule>

Source: http://stackoverflow.com/a/19839609


Leave a Reply