How to Set up a HTTP to HTTPS Redirect on Webfaction
Setting up a HTTP to HTTPS redirect would ensure your users automatically land on the secure site (the one with the SSL certificate installed) even if they have entered the URL of your domain using the insecure http (without the s) protocol.
Once you have installed an SSL/TLS certificate for your domain, it’s possible to automatically redirect visitors to your secured site https://www.yoursite.com (http with an s) even if they have entered http://www.yoursite.com(without the s).
Log in your Webfaction account to do the following steps.
Part A – Create a new static app to act as redirect from http to https
1. Add a new static app
2. Give your new app a name and select Static and the latest PHP version supported by your server
Click on Save. This will create a new app under your /home/username/webapps folder.
3. With a text editor create an .htaccess file with these lines
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-SSL} !on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
4. Upload the .htaccess file to your new app folder and change file permissions to 664
I used Filezilla to do the upload.
The content of your new app folder would have two files:
Part B – Edit your domain website to use the new redirect app
5. Click on the Websites sub-tab under Domain/Websites tab
6. Click on your current website, http://www.yoursite.com (unsecured website, without s) to edit it
7. Click on the X icon to remove the app that currently serves your unsecured website
8. Click on Add an application the use an existing application, select the app you created in Part A. Click on Save.
9. Testing
Wait for a couple of minutes then test the redirect by entering http://www.yoursite.com (without s) in your browser. If the redirect works the browser should automatically load https:/www.yoursite.com (with s).
Happy redirect .
Additional Resources
Thanks! This method works great and saved me lots of time!
Thanks. The instructions still work great in October 2019!
What is the small blue wire for in the first harness