mardi 1 novembre 2016

apache2 redirecting to https://www

I am trying to make any request that comes to my laravel website to redirect to https://www. because Google Analytics complains. After a lot of googling and reseaching my .htaccess file looks like the following. (My site is running at AWS EC2 behind an Elastic Load Balancer)

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

RewriteEngine On

RewriteCond %{HTTP_USER_AGENT} !^ELB-HealthChecker
RewriteCond %{REQUEST_SCHEME} http [OR]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^ https://www.example.com%{REQUEST_URI} [NE,L,R]

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

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]


</IfModule>

When I save the new .htaccess file and I restart apache I get a 504 error in Chrome saying that the website www.example.com redirected you too many times. Try deleting your cookies.

When I delete my cookies or I visit example.com from incognito it works perfectly! But how can I force the users to delete their previous cookies so that they do not get too many redirections?

Thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire