Skip to content

Instantly share code, notes, and snippets.

@akhileshdarjee
Created April 13, 2022 08:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akhileshdarjee/425e7158fe3004a46d9e6228f15528f9 to your computer and use it in GitHub Desktop.
Save akhileshdarjee/425e7158fe3004a46d9e6228f15528f9 to your computer and use it in GitHub Desktop.
Let's Encrypt - Redirect everything to HTTPS
Let's Encrypt(Certbot) redirect everything to HTTPS:
1. Run the following command
certbot --apache -d yourdomain.com -d www.yourdomain.com
2. Navigate to your domain Apache2 conf file and scroll to the bottom. You'll see something like this:
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.yourdomain.com [OR]
RewriteCond %{SERVER_NAME} =yourdomain.com
RewriteRule ^ %{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
From the above code replace the following line:
RewriteRule ^ %{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
with
RewriteRule ^ https://yourdomain.com%{REQUEST_URI} [END,NE,R=permanent]
Note:
Replace 'yourdomain.com' with your desired domain
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment