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 ^(.*)$$1 [R,L]

Be sure to replace 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 ^(.*)$$1 [R,L]

Make sure to replace example\.com with the domain name you're trying force to https. Additionally, you need to replace 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 ^(.*)$$1 [R,L]

Make sure you change the folder reference to the actual folder name. Then be sure to replace 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


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

sample :  and


thank you


32,263 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 ^(.*)$$1 [R,L]

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

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!

22,952 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,
n/a Points
2016-04-01 9:03 am

when i add the above code the site going down .


22,952 Points
2016-05-09 10:49 am
Hello faiz,

Thank you for contacting us. If you are using a CMS (such as WordPress, Joomla, Drupal, etc.) I recommend using a Plugin, or module to avoid conflicts.

Are you getting any error messages?

Best Regards,
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 ^(.*)$$1 [R,L]And this is what was displayed in the browser window:

"An error occurred during a connection to 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.

36,928 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
n/a Points
2016-05-09 5:41 am


my host is Siteground and the it wrote me this code that write in htaccess

RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$$1 [R,L]


And it works perfect.

n/a Points
2016-05-09 8:26 am

This approach is better, automatically gets your URI:


RewriteEngine On

RewriteCond %{HTTPS} off

RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

n/a Points
2016-05-11 9:19 pm

Yes it did perfectly worked for me.... Thanks a lot .... I was after this solution for about two days....

n/a Points
2016-05-27 4:05 pm

What about domains that don't use "www". Actually, I need ssl for both the "www" and the non-www versions of my site.

Should I add anything more to the code?

9,538 Points
2016-05-28 12:08 am
Hello Steve,

You should not have to add anything as long as your SSL is setup for the www version and non-www version.

Best Regards,
TJ Edens

Post a Comment

Email Address:
Phone Number:

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

19 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?


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:
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!