Htaccess Laravel 4 Forwarding

I have a Laravel 4 installation and I used the htaccess template to redirect my site:

site.com.brbefore www.site.com.br(pay attention to www ).

But when I use a route, for example site.com.br/TITLE-OF-MY-POST, I am redirected to:

www.site.com.br/index.php instead www.site.com.br/TITLE-OF-MY-POST"

Does anyone know why? Here are my htaccess rules:

Laravel Rule

<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On

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

Boiler rule rule

<IfModule mod_rewrite.c>
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
+4
source share
1 answer

Reorder your rules:

<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>

In general, keep your 301 rules in front of internal rewriting rules.

+5
source

All Articles