Forcing https and www

Gandalf ! I feel like you are an old friend already - do you ever sleep? :smiley:

you need to redirect users to the chosen version in your .htaccess file (assuming you’re running on Apache).

I am on Apache and I know how to edit files and can find .htaccess but have no idea how to do this - what would the syntax be to direct all visitors / search engines to

https://www.mywebsite.com

Hi @kerry14 I have moved this post to Server Config as it’s not a marketing question any longer :slight_smile:

To force https and www you’ll need the following in your .htaccess file:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^mywebsite\.com
RewriteRule .? https://www.mywebsite.comk%{REQUEST_URI} [R=301]
RewriteCond %{SERVER_PORT} ^80$
RewriteRule .? https://www.mywebsite.com%{REQUEST_URI} [R=301,L]
2 Likes

@Gandalf - hi I don’t really understand ,htaccess or 301 redirects but I am guessing -

RewriteRule .? https://www.mywebsite.comk%{REQUEST_URI} [R=301]

is a typo - should be .com not .comk yeah ?

That looks like a typo to me.

Yup, it’s a typo! :blush:

1 Like

All seems to be good now - one tip I will share, be careful your chosen editor does not save the file as .htaccess.txt. I have been troubleshooting this all day and then noticed my .htaccess was now .htaccess.txt, I renamed it and all is great now - thanks guys

2 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.