InMotion Hosting Support Center

Sometimes it's necessary to make sure your website’s visitors use the SSL encrypted connection. If you’re not familiar with SSL and would like to know more please review our article “What is SSL and Why is it important?” If you need assistance using the shared SSL that InMotion Hosting offers to shared hosting customers, please see our article on "forcing your visitors to use the shared ssl". Click here to learn more about Dedicated Hosting.

Forcing visitors to use SSL can be accomplished through your .htaccess file using mod_rewrite. If you’d like more information on mod_rewrite please read our article.

If you are using the Premium Website Builder and need to force your website traffic over SSL, please see the following article instead:
How to force your Premium Website Builder website over SSL

To force all web traffic to use HTTPS insert the following lines of code in the .htaccess file in your website’s root folder.

Important:If you have existing code in your .htacess, add this above where there are already rules with a similar starting prefix.

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

Be sure to replace www.example.com with your actual domain name.

To force a specific domain to use HTTPS, use the following lines of code in the .htaccess file in your website's root folder:

RewriteEngine On 
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

Make sure to replace example\.com with the domain name you're trying force to https. Additionally, you need to replace www.example.com with your actual domain name.

If you want to force SSL on a specific folder you can insert the code below into a .htaccess file placed in that specific folder:

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteCond %{REQUEST_URI} folder 
RewriteRule ^(.*)$ https://www.example.com/folder/$1 [R,L]

Make sure you change the folder reference to the actual folder name. Then be sure to replace www.example.com/folder with your actual domain name and folder you want to force the SSL on.

If you need further assistance please feel free to ask a question on our support center website.

Support Center Login

Social Media Login

   
Social Login Joomla

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question
n/a Points
2015-12-30 9:16 pm

Hi

I would like to interesting how can I set just 1 or 2 pages?

sample : xxx.com/cart  and xxx.com/checkout

 

thank you

victor

Staff
31,871 Points
2015-12-31 10:38 am
Hello Victor,

Your SSL would still need to be for the domain, but then the code would be exactly the tutorial displays above for the folders:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} folder
RewriteRule ^(.*)$ https://www.yourdomain.com/folder/$1 [R,L]


If you have any further questions or comments, please let us know.

Regards,
Arnel C.
n/a Points
2016-01-20 1:13 pm

Thanks, nice somple howto.

n/a Points
2016-02-18 2:46 pm

Is there a way to force SSL on a single post in wordpress via the .htaccess codes above? Thanks!

Staff
22,444 Points
2016-02-18 6:52 pm
Hello Joe,

Thank you for contacting us. Since you are using WordPress (which also relies on .htaccess rules), I recommend using a plugin instead of adding a .htaccess rule directly.

This is to avoid a rule interfering with the functionality of your website.

Thank you,
John-Paul
n/a Points
2016-04-19 10:15 pm

This is the coding I had in my .htaccess file:

##### RewriteEngine enabled - BEGINRewriteEngine On##### RewriteEngine enabled - ENDRewriteCond %{HTTP_HOST} ^mydomainname\.com [NC]RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.mydomainname.com/$1 [R,L]And this is what was displayed in the browser window:

"An error occurred during a connection to www.mydomainname.com. SSL received a record that exceeded the maximum permissible length. Error code: SSL_ERROR_RX_RECORD_TOO_LONG"

 

Of course I substituted mydomainname with the name of my domain.

Please advise.

Staff
36,223 Points
2016-04-20 9:28 am
Hello Jim,

The error message indicates that the redirect is working as it is an SSL error message. You will want to check the SSL itself to make sure it is a) setup at all and b) set up correctly.

Kindest Regards,
Scott M

Post a Comment

Name:
Email Address:
Phone Number:
Comment:
Submit

Please note: Your name and comment will be displayed, but we will not show your email address.

8 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?

Search

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!