dimanche 11 octobre 2015

Laravel 5.1 Force non-WWW and HTTPS Not Working

I am trying to force https and non-www on my laravel site. Here is my .htaccess file:

RewriteEngine On

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]

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

#if the request is not secure
RewriteCond %{HTTPS} off
#redirect to the secure version
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]

#Redirect to non-WWW
RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteRule ^(.*) https://example.com/$1  [QSA,L,R=301]

Here are the current redirects

example.com                  => https://example.com           (GOOD)
www.example.com              => https://example.com           (GOOD)
https://example.com          => https://example.com           (GOOD)
http://ift.tt/1LeSc2o     => http://ift.tt/1LeSc2o      (GOOD)

example.com/asdf             => http://ift.tt/1sDtrIl (BAD)
www.example.com/asdf         => http://ift.tt/1sDtrIl (BAD)
http://ift.tt/1LeSarx => http://ift.tt/1sDtrIl (BAD)

I can't figure out why it's redirecting to the index.php file when I'm not on the main page.

Edit: The 'asdf' is a username variable and it changes but, the same view is loaded for all usernames.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire