Skip to content

Instantly share code, notes, and snippets.

View Ramesh-X's full-sized avatar
🏖️

Ramesh Pramuditha Rathnayake Ramesh-X

🏖️
View GitHub Profile
@Ramesh-X
Ramesh-X / .htaccess
Created January 10, 2019 06:00 — forked from vielhuber/.htaccess
Apache: htaccess force www and https ssl #server
# force HTTPS and www.
RewriteEngine On
RewriteCond %{HTTP_HOST} (?!^www\.)^(.+)$ [OR]
RewriteCond %{HTTPS} off
RewriteRule ^ https://www.%1%{REQUEST_URI} [R=301,L]
# alternative way
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]