WebFaction
Community site: login faq

I've been out of the website game for a while now and I can't figure out what I'm doing wrong. I'm more of a graphics person. >.<

shouldn't I be able to type www.website.com instead of Https://www.website.com?

I have a hankering it's some type of redirect but I don't know where to start. Any helpful comments would be appreciated.

Thanks! Ian Monty

asked 03 Oct, 01:49

fawwal
213
accept rate: 0%


In your control panel you need to explicitly add www.yourdomain.com as a domain name for your application that contains the redirect logic, and then you need to ensure you have the proper logic set up in your redirect application to direct people where they need to go. There's a couple ways to go about this, but here's what I do personally.

I create a dedicated application within the WebFaction control panel to handle all my redirects and nothing else. This should be a static/php application, and the only file it needs is a .htaccess file with something like the following:

RewriteEngine On

# ----- Don't redirect .well-known (required for letsEncrypt) -----
RewriteRule ^\.well-known - [L,NC]

# ----- Redirect HTTP -> HTTPS and remove www. -----
RewriteCond %{HTTP_HOST} ^www\. [OR]
RewriteCond %{HTTPS} off
RewriteCond http%1://%{HTTP_HOST} ^(https?://)(www\.)?(.+)$
RewriteRule ^ https://%3%{REQUEST_URI} [R=301,L]

# ---- If Nothing Above Matches, show a blank 404 -----
RewriteRule ^ - [L,R=404]

I also usually have other redirects in this file as well, but I've omitted them for brevity.

Then in your control panel, make this an http website, and add www.yourwebsite.com and yourwebsite.com as the domain names. You could also create an additional website that is https with www.yourwebsite.com using the same redirect application.

After that you just have your application set up like normal, whatever it may be, using https, and yourwebsite.com as the domain name without the www. prefix, without your application being blissfully unaware of any redirect logic.

What the code above does:

It first ignores any redirect rules for anything that begins with anydomain.com/.well-known/, as that is used by LetsEncrypt to verify your website's identity.

It then checks if the url supplied starts with www. or is http, and if so, will redirect the user to the https://www. version of the same URL.

Hope that all makes sense, if you're having any further issues I can try to help.

permanent link

answered 26 Oct, 14:59

bh-scott
235
accept rate: 0%

I should also mention that another benefit to doing redirects this way is that this same redirect application can be re-used for however many websites and domains you may have.

(26 Oct, 15:01) bh-scott

Welcome back.

As per, https://docs.webfaction.com/user-guide/websites.html?highlight=secure#secure-sites-https

"If you need your site to be available over both HTTP and HTTPS, then create two website records, one HTTP and the other HTTPS, and ensure that both sites are assigned to the same IP address."

My guess is that you might not have a second site record setup for HTTP.

permanent link

answered 03 Oct, 02:09

NickR ♦♦
4165
accept rate: 18%

Thanks for the Reply Nick. I've got the Http:// and Https:// redirects working. I'm having trouble when I just type in www.website leaving out the http.

It shows a Webfaction splash. How DO I correct this?

If you navigate to any popular website and remove the http:// from the address bar it reverts to http?

(03 Oct, 02:26) fawwal
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×124
×74

question asked: 03 Oct, 01:49

question was seen: 245 times

last updated: 26 Oct, 15:01

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2016 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM