Showing posts with label HTTPS. Show all posts
Showing posts with label HTTPS. Show all posts

Thursday 11 October 2018

How to redirect www to non www AND http to https in AWS .htaccess


AWS WWW to non WWW redirection
RewriteEngine On
RewriteCond %{SERVER_NAME} =www.example.com
RewriteRule ^.*$ https://example.com%{REQUEST_URI}
AWS HTTP to HTTPS redirection
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^.*$ https://example.com%{REQUEST_URI}
AWS WWW to non WWW and HTTP to HTTPS
RewriteEngine On
RewriteCond %{SERVER_NAME} =www.example.com
RewriteRule ^.*$ https://example.com%{REQUEST_URI}
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^.*$ https://example.com%{REQUEST_URI}

Tuesday 29 May 2018

How to force redirect HTTP to HTTPS in AWS or any other server using .htaccess

1st Method
<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule .* https://%{HTTP:Host}%{REQUEST_URI} [L,R=permanent]

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

2nd Method
<IfModule mod_rewrite.c>
     RewriteEngine On
     RewriteCond %{HTTPS} !on
     RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>