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

Our Login page has moved, Click the button below to be taken to the login page.

Social Media Login

   
Social Login Joomla

Related Questions

Here are a few questions related to this article that our customers have asked:
Redirecting http into https
Would you like to ask a question about this page? If so, click the button below!
Ask a Question
n/a Points
2017-09-10 2:58 pm

Our (multisite) WordPress website has an issue: I configured it so http would be forced to https. So far so good and it worked like a charm! However, recently I discovered that the redirect is forced whereas the specific URL is "forgotten" (e.g. mydomain.com/site1/register would become https://www.mydomain.com). Very uncomfortable as users are not registrating at the correct page!

This is the current .htaccess file with is not providing the desired result:

# BEGIN WordPress

RewriteEngine On

RewriteBase /

RewriteRule ^index\.php$ - [L]

RewriteCond %{HTTPS} !=on

RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R=301,NC,L]

 

# add a trailing slash to /wp-admin

RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

 

RewriteCond %{REQUEST_FILENAME} -f [OR]

RewriteCond %{REQUEST_FILENAME} -d

RewriteRule ^ - [L]

RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]

RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]

RewriteRule . index.php [L]

# END WordPress

 

# Block WPRegister en WPLogin

RewriteCond %{HTTP_HOST} ^([^.:]+.)www.mydomain.com/login/?action=register.?(:[0-9]*)?$ [NC]

RewriteRule ^/(.*)$ www.mydomain.com/register/$1 [R=302,L]

 

# Rewrite wp-signup

Redirect 301 /wp-signup.php https://www.mydomain.com/register

I hope you're able to check it to see what's wrong...

Bas

Staff
30,388 Points
2017-09-11 9:51 am
Since WordPress relies on .htaccess rules, adding rules directly can interfere with WordPress functionality. Instead, I recommend updating your actual domain names in the WordPress dashboard to reflect the SSL. For example, change "http://example.com" to "https://example.com".

Thank you,
John-Paul
n/a Points
2017-09-06 2:03 am

REALLY dumb question here...

my htaccess has this:

# Use PHP52 as defaultAddHandler application/x-httpd-php53 .php

 

Do I add the Rewright engine stuff below what's already there or above it? The PHP52 stuff looks like some kind of heading that needs to be at the top.

 

Thanks, Bob

Staff
40,336 Points
2017-09-06 5:45 am
Hello Bob,

Thanks for the question about the .htaccess file. As the file is processed from top to bottom, then yes, any add handler setting should be set at the top to have priority. Be aware that they are deprecating php 5.2.

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

Kindest regards,
Arnel C.
n/a Points
2017-09-06 4:51 pm

Thank you Arnel,

I tried it both ways last night without success. I tried it again now and it doesnt work. I have this:

RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.*******.com/$1 [R,L]# Use PHP52 as defaultAddHandler application/x-httpd-php53 .php

 

I get error 404 Not found

The document you are looking for may have been removed or re-named. Please contact the web site owner for further assistance.

 

n/a Points
2017-09-06 5:19 pm

Thank you Arnel,

I fixed it. I was in the wrong .htaccess file

n/a Points
2017-08-07 12:22 pm

Just want to point out that the line in the text above:

 

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

specifies an incorrect filename. If someone's not paying attention and doesn't read the whole page, this will be problematic.

n/a Points
2016-12-17 12:42 am
Also, if you could help me out a bit more. My site structure is: www.mydomain.com/ (contains 1 WP-installation) www.mydomain.com/subSite1/ (contains another WP-installation) www.mydomain.com/subSite2/ (contains third WP-installation) How can I create additional redirects, so also my subSites would be forced to redirect to https? I have tried different variations on subSite's htaccess files, but with no luck. Ted
Staff
43,761 Points
2016-12-19 4:36 pm
Our guide on 301 redirects for your site should help you with the proper configuration.
n/a Points
2016-12-16 9:10 pm
Hi, and thank you for such a great source of information. Google's best practices for http to https migration says that 301 redirects should be used. https://support.google.com/webmasters/answer/6073543?hl=en Should this code to be altered somehow to achieve the 301 effect? I assume that doing this without 301 will effect site's 'link juice' RewriteEngine On RewriteCond %{HTTP_HOST} ^example\.com [NC] RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.example.com/$1 [R,L] Would changing [R,L] to [R=301,L] do the trick? Sincerely Ted
Staff
43,761 Points
2016-12-19 4:34 pm
Yes, setting the [R,L] to [R=301,L] should work.
n/a Points
2016-07-30 2:39 pm

Hi Guys,

 

I had shifted my website from http to https.I'm only able to access backpanel of the website not front end. Front end is showing error too much redirection of www.lenstry.com. Can you guys please help me. My website is lenstry.com on prestashop 1.6. 

Staff
43,761 Points
2016-08-01 4:05 pm
I am not showing any errors when visiting the site. Were you able to correct the issue?
n/a Points
2015-11-30 11:34 pm

Hi, Good morning, the following is the htaccess code of my word press site -

# BEGIN WordPress

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteBase /

RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]

</IfModule>

 

# END WordPress

how do i modify it redirect to https?

kindly help. regards.

Staff
10,077 Points
2015-12-01 10:20 am
Hello Ashish,

Instead of editing the .htaccess file I would suggest changing the settings within WordPress Settings or use a plugin to force the SSL that way it will not conflict with what WordPress has in its database.

Best Regards,
TJ Edens
n/a Points
2015-12-02 8:50 am

Thanks sir, Mr. T J Edens. Changed the settings in word press and it is working fine now. Regards.

n/a Points
2015-11-16 1:25 am

Hi,

I have a wordpress site in a subfolder "wordpress" and I want my WP site to be ssl with no page left out. I changed wordpress address (url) to https://domain.com/wordpress and site addressl (url) to https://domain.com

I added this to my .htaccess file

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

...and ssl is forced in the following locations; wp-admin and my home page. My pages works with ssl if I enter them with https however they still load and remain http if I enter the address as http - same as domain.com/page without entering the protocol.

How can I make the pages force to https even when http url is entered?

Staff
43,761 Points
2015-11-16 3:34 pm
Hello Paul,

Have you set the URL settings within the dashboard to https:// also?

Kindest Regards,
Scott M
n/a Points
2015-12-02 12:39 pm

Hi Scott,

Yes I did.

I have now resolved the issue by forcing ssl at the root. One issue I had using this method was that my 404 pages didn't work properly as they would redirect to my cgi-bin folder with no actual content.

What I have come to realize is that Wordpress have less issues when it's sitting at the root of the website rather than having it in a sub directory. Going forward I will always install wordpress in the root folder. That way I can avoid unecessary issues that are difficult to track down.

n/a Points
2015-11-13 8:33 am

Hello,

In one of my website I have ssl certificate. On the same website I am fetching visitors location on basic of their IP address and for that I am using http://ip-api.com/json/.

The problem this url works well with http but as my htaccess file redirecting all http to https, so this url also become https://ip-api.com/json/ and it does not return anything.

So, is there any way through which I can restrict http://ip-api.com/json/ not to attach https and it should remain like http://ip-api.com/json/.

I was trying so many options but unable to get the solution. I would be very thankful, if someone help me to solve this.

Best Regards,

Suraj

Staff
10,077 Points
2015-11-13 10:02 am
Hello Suraj,

Please try the .htaccess code below and let me know if it works for you.

RewriteEngine On

RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} ^/json
RewriteRule ^(.*)$ http://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]

RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/json
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]

Best Regards,
TJ Edens
n/a Points
2015-11-14 5:06 am

Hello,

Is there a way to write .htaccess file in below way

if the website is say abc.com and if someone visits abc.com then url should not get appended with https i.e. is should not become https://abc.com.

If someone visits abc.com/search/ then that url should get appended with https and should become  https://abc.com/search/

Is there a way to achieve it? If yes, then please share it with me.

Best Regards,

Suraj

n/a Points
2015-10-14 4:13 pm

HelloI have one urgent thing with ssl.In my prestashop store, category pages are redirected to wrong ones after ssl is allowed.

But all category links are correctly, only redirect to wrong category ones. 

site is buy.edisplayinc.com

if you check my store, you can know issue in category pages.what solution for that?want your helping ASAP.

Thanks.Peder

Staff
40,336 Points
2015-10-14 7:40 pm
Hello Peder,

I looked at your PrestaShop store and none of the links are using SSL. Did you enable them in PrestaShop? Do you have a certificate for your domain? When I look at your category pages, I'm not seeing the issue you're referring to. You may also want to turn off SEO friendly links temporarily, then reset them if you're changing the URLs to use SSL. Provide us more information and we can look into the issue further.

Regards,
Arnel C.
2015-10-15 12:33 am
Hello Arnel.
Thanks for your reply.
Now only checkout and myaccount pages are using the SSL and rest are not.
my store have 3 main categories (commercial displays, media players, digital singage packages) ,but all categories have only products in commercial LED TV (this is just sub-category in Commercial Displays)
buy.edisplayinc.com/en/commercial-displays
buy.edisplayinc.com/en/media-players
buy.edisplayinc.com/en/digital-signage-packages

Btw let me know what infos do you need more.

Thanks
Peder.
2015-10-15 1:05 am
Hi, Arnel.
Thanks again.
But I think this is solution and it is no related with htaccess file.
I don't use the ssl on every pages, only check out and my account pages.
those pages work fine, but problem is just in category pages which doesn't use the ssl .
do you understand for me?
what solution?

Thanks.
Peder.
Staff
40,336 Points
2015-10-16 3:29 pm
Hello Peder87,

When I'm looking at your website, I see SEF friendly URLs in the category area. This is a SETTING in your PrestaShop backend. You should start by first disabling SEF, and then also make sure that any caching is turned off as well. This is issue is related with how these pages are linked, and these settings may affect those links and how they're being generated. If you continue to have problems, then please provide us access as an admin to your PrestaShop backend so that we can look at it. Otherwise, if you do not wish to share access, then you may want to consult with PrestaShop's support forum or obtain direct support with PrestaShop.

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

Regards,
Arnel C.
n/a Points
2015-10-13 5:19 pm

Hi,

I have a WP site, and it currently has SSL on all of the site pages.

However, there are two pages that I want to force a non SSL (http) because they have iframes from http sites.

Would anyone be able to help me with those rewrite rules?

Thanks so much,

Amanda

Staff
10,077 Points
2015-10-14 12:48 am
Hello Amanda,

There is no way to currently do that unless you manually forced the SSL on each page/post. This can be done by older plugins however they are severely outdated and we do not recommend them. Can you just use https:// on the src for your iframe?

Best Regards,
TJ Edens
n/a Points
2015-09-23 12:27 pm

Hi Sir, recently i installed Digital Certificate on my domain i.e. www.roboshop.in

in my .htacces file following codes are there . I want to know what will be the mofdification required by which it open by https by default

 

RewriteCond %{HTTP_HOST} !^www\. 

RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

 

redirect 301 /index.php?route=product/product&product_id=174 http://www.roboshop.in

Staff
40,336 Points
2015-09-24 9:41 am
Hello Ramesh,

The article above uses the .htaccess file to re-direct any queries to use the HTTPS URL of your domain. So, if you're using the code correctly then anyone going to your website is automatically re-directed to use HTTPS even if they didn't not specify that in their browser. If you're using an application for your website that requires configuration for HTTPS, then you may need to configure those settings. For example, some ecommerce programs require that you specify the HTTPS configuration in the application's preferences.

I hope this helps to answer your question, please let us know if you require any further assistance.

Regards,
Arnel C.
n/a Points
2015-09-04 9:42 am

I changed my .htaccess as indicated above but i am still getting the same error. I was told that i should change my CSR to use SHA-2, it is currently using SHA-1. If this is the case, can you tell me the name of a SSL that i can purchase that uses SHA-2. I'm currently using PositiveSSL

Staff
10,077 Points
2015-09-04 4:58 pm
Hello Roxanne,

You can still use a positive SSL however you need to have your host generate a new CSR and have the SSL re-keyed. You would just submit the CSR to who ever sold you the SSL and ask for it to be updated to a SHA-2.

Best Regards,
TJ Edens
n/a Points
2015-08-30 1:16 pm

hello i used the first solution that appears in this paper which is  at the last of this post, i see that everything works fine except for that when i access https://mysite.com i dont get redirected to https://www.mysite.com! how can i add to that solution so i can make https://mysite.com redirects to https://www.mysite.com

 

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]
Staff
43,761 Points
2015-08-31 12:56 pm
Hello Rok,

You will want to check out our article on forcing www in htaccess.

Kindest Regards,
Scott M
n/a Points
2015-08-29 9:42 am

Hi I'm having trouble with my htaccess, every-time I try to get it to take the viewer to the SSL version of the site using the code it just gives me a redirect error (too many redirects)

 

RewriteEngine On

RewriteCond %{SERVER_PORT} 80

RewriteRule ^(.*)$ https://www.scryptedhosting.com/$1 [R,L]

 

Can anyone help?

Staff
43,761 Points
2015-08-31 1:02 pm
Hello Tom,

Check the htaccess file to see if there is another conflicting rule. That is normally the cause of this type of error

Kindest Regards,
Scott M
n/a Points
2015-08-18 11:40 pm

Hi Arnel,

Thanks much for your reply.  

I tried a few different plugins to redirect my site to https but none of them worked.  I tried changing my wp-config.php file with the link you sent in the previous post, but it's not really working out.  Not sure if the code I wrote isn't correct but this is what I wrote after  require_once(ABSPATH . 'wp-settings.php')  line.  Can you point out what's wrong here if you can?  Thanks again!

 

/** CUSTOM CODE */

wp_cache_set("siteurl_secure", "https://www.mysite.com/", "options");                              

wp_cache_set("home", ($_SERVER["HTTPS"]?"https://":"http://").$_SERVER["SERVER_NAME"]."/", "options");

 

wp_cache_set("siteurl", get_settings("home")."/", "options");

 

Staff
40,336 Points
2015-08-19 10:30 am
Hello Ji,

The code you're showing is for caching and not for re-directing your domain. This does point out that you are using caching. You should definitely flush the existing cache or at least disable it in order to see if the re-directs are working. Try turning OFF the caching temporarily and putting in your re-directs (or using the suggested plugins). After those are set, either reset or re-load your caching software.

Regards,
Arnel C.
n/a Points
2015-08-13 10:19 pm

Hi Scott,

 

I added the code below

 

<IfModule mod_rewrite.c>
RewriteEngine On 
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} folder/file.html
RewriteRule ^(.*)$ https://diybauen.com/$1 [R,L]
</IfModule>
 

in my .htaccess file for my wordpress site, but it's not redirecting to https:// and it still shows as http://.  I am pasting all the codes from my .htaccess file if you don't mind taking a look at it.  Any help would be appreciated.  Thanks!!

-Ji
---------

# BEGIN WPSuperCache

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteBase /

#If you serve pages from behind a proxy you may want to change 'RewriteCond %{HTTPS} on' to something more sensible

AddDefaultCharset UTF-8

RewriteCond %{REQUEST_URI} !^.*[^/]$

RewriteCond %{REQUEST_URI} !^.*//.*$

RewriteCond %{REQUEST_METHOD} !POST

RewriteCond %{QUERY_STRING} !.*=.*

RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$

RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\"]+ [NC]

RewriteCond %{HTTP:Profile} !^[a-z0-9\"]+ [NC]

RewriteCond %{HTTP_USER_AGENT} !^.*(2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800).* [NC]

RewriteCond %{HTTP:Accept-Encoding} gzip

RewriteCond %{HTTPS} on

RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{SERVER_NAME}/$1/index-https.html.gz -f

RewriteRule ^(.*) "/wp-content/cache/supercache/%{SERVER_NAME}/$1/index-https.html.gz" [L]

 

RewriteCond %{REQUEST_URI} !^.*[^/]$

RewriteCond %{REQUEST_URI} !^.*//.*$

RewriteCond %{REQUEST_METHOD} !POST

RewriteCond %{QUERY_STRING} !.*=.*

RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$

RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\"]+ [NC]

RewriteCond %{HTTP:Profile} !^[a-z0-9\"]+ [NC]

RewriteCond %{HTTP_USER_AGENT} !^.*(2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800).* [NC]

RewriteCond %{HTTP:Accept-Encoding} gzip

RewriteCond %{HTTPS} !on

RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{SERVER_NAME}/$1/index.html.gz -f

RewriteRule ^(.*) "/wp-content/cache/supercache/%{SERVER_NAME}/$1/index.html.gz" [L]

 

RewriteCond %{REQUEST_URI} !^.*[^/]$

RewriteCond %{REQUEST_URI} !^.*//.*$

RewriteCond %{REQUEST_METHOD} !POST

RewriteCond %{QUERY_STRING} !.*=.*

RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$

RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\"]+ [NC]

RewriteCond %{HTTP:Profile} !^[a-z0-9\"]+ [NC]

RewriteCond %{HTTP_USER_AGENT} !^.*(2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800).* [NC]

RewriteCond %{HTTPS} on

RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{SERVER_NAME}/$1/index.html -f

RewriteRule ^(.*) "/wp-content/cache/supercache/%{SERVER_NAME}/$1/index.html" [L]

 

RewriteCond %{REQUEST_URI} !^.*[^/]$

RewriteCond %{REQUEST_URI} !^.*//.*$

RewriteCond %{REQUEST_METHOD} !POST

RewriteCond %{QUERY_STRING} !.*=.*

RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$

RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\"]+ [NC]

RewriteCond %{HTTP:Profile} !^[a-z0-9\"]+ [NC]

RewriteCond %{HTTP_USER_AGENT} !^.*(2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800).* [NC]

RewriteCond %{HTTPS} !on

RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{SERVER_NAME}/$1/index.html -f

RewriteRule ^(.*) "/wp-content/cache/supercache/%{SERVER_NAME}/$1/index.html" [L]

</IfModule>

 

# END WPSuperCache

 

# BEGIN WordPress

 

 

 

 

# BEGIN WPSuperCache

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteBase /

#If you serve pages from behind a proxy you may want to change 'RewriteCond %{HTTPS} on' to something more sensible

AddDefaultCharset UTF-8

RewriteCond %{REQUEST_URI} !^.*[^/]$

RewriteCond %{REQUEST_URI} !^.*//.*$

RewriteCond %{REQUEST_METHOD} !POST

RewriteCond %{QUERY_STRING} !.*=.*

RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$

RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\"]+ [NC]

RewriteCond %{HTTP:Profile} !^[a-z0-9\"]+ [NC]

RewriteCond %{HTTP_USER_AGENT} !^.*(2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800).* [NC]

RewriteCond %{HTTP:Accept-Encoding} gzip

RewriteCond %{HTTPS} on

RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{SERVER_NAME}/$1/index-https.html.gz -f

RewriteRule ^(.*) "/wp-content/cache/supercache/%{SERVER_NAME}/$1/index-https.html.gz" [L]

 

RewriteCond %{REQUEST_URI} !^.*[^/]$

RewriteCond %{REQUEST_URI} !^.*//.*$

RewriteCond %{REQUEST_METHOD} !POST

RewriteCond %{QUERY_STRING} !.*=.*

RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$

RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\"]+ [NC]

RewriteCond %{HTTP:Profile} !^[a-z0-9\"]+ [NC]

RewriteCond %{HTTP_USER_AGENT} !^.*(2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800).* [NC]

RewriteCond %{HTTP:Accept-Encoding} gzip

RewriteCond %{HTTPS} !on

RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{SERVER_NAME}/$1/index.html.gz -f

RewriteRule ^(.*) "/wp-content/cache/supercache/%{SERVER_NAME}/$1/index.html.gz" [L]

 

RewriteCond %{REQUEST_URI} !^.*[^/]$

RewriteCond %{REQUEST_URI} !^.*//.*$

RewriteCond %{REQUEST_METHOD} !POST

RewriteCond %{QUERY_STRING} !.*=.*

RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$

RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\"]+ [NC]

RewriteCond %{HTTP:Profile} !^[a-z0-9\"]+ [NC]

RewriteCond %{HTTP_USER_AGENT} !^.*(2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800).* [NC]

RewriteCond %{HTTPS} on

RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{SERVER_NAME}/$1/index.html -f

RewriteRule ^(.*) "/wp-content/cache/supercache/%{SERVER_NAME}/$1/index.html" [L]

 

RewriteCond %{REQUEST_URI} !^.*[^/]$

RewriteCond %{REQUEST_URI} !^.*//.*$

RewriteCond %{REQUEST_METHOD} !POST

RewriteCond %{QUERY_STRING} !.*=.*

RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$

RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\"]+ [NC]

RewriteCond %{HTTP:Profile} !^[a-z0-9\"]+ [NC]

RewriteCond %{HTTP_USER_AGENT} !^.*(2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800).* [NC]

RewriteCond %{HTTPS} !on

RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{SERVER_NAME}/$1/index.html -f

RewriteRule ^(.*) "/wp-content/cache/supercache/%{SERVER_NAME}/$1/index.html" [L]

 

</IfModule>

 

# END WPSuperCache

 

# BEGIN WordPress

 

 

<IfModule mod_rewrite.c>

RewriteEngine On 

RewriteCond %{SERVER_PORT} 80

RewriteCond %{REQUEST_URI} folder/file.html

RewriteRule ^(.*)$ https://diybauen.com/$1 [R,L]

</IfModule>

 

 

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteBase /

RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]

</IfModule>

 

 

# END WordPress

 

Staff
40,336 Points
2015-08-14 8:50 am
Hello Ji,

Sorry for the problems with your WordPress site and forcing it to use https. I checked on WordPress support forums for this and the code above does not work for WordPress (see the post). The answer in the forum post advises to make changes in the wp-config.php file. You can also search for plugins which will make the necessary changes for you. Here's an example of one.

I hope this helps to answer your question, please let us know if you require any further assistance.

Regards,
Arnel C.





n/a Points
2015-08-10 11:26 am

I have the following rule in the .htaccess which is working ok for the domain but when i go to the second site section in WP, for example the domain.com/es it not forcing https (im using wpml)

<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.domain.net/$1 [R,L] </IfModule>

Staff
43,761 Points
2015-08-10 12:49 pm
Hello Manuel,

The code appears as it should work. Have you set up a test scenario outside the WordPress environment to see if it still works?

Kindest Regards,
Scott M
n/a Points
2015-07-31 8:59 am

It is very important to add this rules at the TOP of the .htacceess file.

Staff
10,077 Points
2015-07-31 9:42 am
Hello Serg,

Not always but the .htaccess file works top down, so if one rewrite conflicts with another, the top one will take dominance.

Best Regards,
TJ Edens
n/a Points
2015-07-21 11:47 pm

Hi, would there be a reason that the FireFox browser doesn't respond to my htaccess file? Safari, Google and even Opera are redirecting, but not FireFox. Any specific code for this? Thanks. 

Staff
40,336 Points
2015-07-22 9:34 am
Hello Greg,

To my knowledge there is no reason why .htaccess would not be working on Firefox. My guess would be that you need to clear the browser cache. Please try that first and let us know if the problem still occurs. We would need to see the URL that you're referring in order to test it as well.

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

Regards,
Arnel C.
n/a Points
2015-07-10 6:57 am

hi i need some help  i have made an htaccess file.i have redirect two pages to https use this codeRewriteCond %{HTTPS} offRewriteCond %{REQUEST_URI} ^(forgot|login)/?.*$RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]but not redirect pages to https 

Staff
30,388 Points
2015-07-10 12:48 pm
Hello jammy,

Thank you for contacting us. Here is a link to our guide on setting up a redirect in your .htaccess.

If you are having trouble creating the redirect rule, you can also create a redirect in cPanel. This will create/add the rule to your .htaccess file for you.

Thank you,
John-Paul
n/a Points
2015-05-25 10:03 am

hello!

i have a problem like when i'm visiting a site for example google.com/images then ill get a 404 page but in this same case crazydevelopers.in/images (my site) i can view images that means every one can acess my folders , so please provide me  code for folders

Staff
10,077 Points
2015-05-27 12:32 am
Hello Rajiv,

You can either place an index.php file in your images directory or you can put the following code in your .htaccess:

Options -Indexes

Best Regards,
TJ Edens
n/a Points
2015-05-21 2:35 pm

Thank You very much it works.....! :)

n/a Points
2015-05-20 5:35 am

doesn't work for me.

clicking any link (apart from contact and checkout) goes to standard http

opencart 1.5.6

http://www.thaimarket.com.au

Staff
40,336 Points
2015-05-21 11:24 am
Hello Daz,

You've given very little information about your current OpenCart settings. Did you enable HTTPS in OpenCart? Please check out this tutorial on enabling the SSL connection in OpenCart. If you have done this, are you getting any errors? What URL settings did you specify for HTTPS? Please check this and let us know if the problem persists. If it does, please let us know how you enabled the OpenCart SSL settings so that we can try to duplicate the problem that you're having.

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

Regards,
Arnel C.
n/a Points
2015-05-04 1:20 am

why isn't the following enough?, why do we have to put port number? Just curious if I am missing the elephant in the room.

this redirects naked url and www url both to https//www. url with wildcard. 

 

RewriteCond %{HTTP_HOST} ^mydomain\.net$ [OR] RewriteCond %{HTTP_HOST} ^www\.mydomain\.net$ RewriteRule ^(.*)$ "https\:\/\/www\.mydomain\.net\/$1" [R=301,L]

Staff
43,761 Points
2015-05-04 8:06 am
Hello Dave,

You can access cPanel or the WHM (for VPS and Dedicated servers) over different ports using the domain name. The port is an extra condition to ensure it redirects only those going over port 80. For the most part, leaving out the port condition will work fine.

Kindest Regards,
Scott M
n/a Points
2015-03-28 12:52 am

hi ssl causing theme issue with my magento store it works fine without ssl 

it does not show any error 

what can be the issue here 

i have magento duplicate store with different ssl providers & 2 different domains 

Staff
43,761 Points
2015-03-30 8:42 am
Hello girish,

Do you mind providing a link to the site so we can see the issue? Also, please describe in detail what issue you are having with the site. I understand that it has to do with teh SSL, but what specifically is the issue? Are things not showing up?

Kindest Regards,
Scott M
n/a Points
2015-02-25 10:08 am

Hi

I have getting an error "However the page includes other resources". When i checked this some of my image src urls added from backend only comes with absolutes path. Can i resolve this using .htacces.

Can anyone help me?

Thanking in advance

 

Nagarajan

 

Staff
43,761 Points
2015-02-27 10:08 am
Hello nagarajan,

Those would need to be resolved within the code files where it calls the absolute paths.

Kindest Regards,
Scott M
n/a Points
2015-03-02 1:57 am

Hi Scott. I resolved my problem. Thank you so much..

n/a Points
2015-02-15 5:42 am

On my WordPress multisite install that uses different subdomains for my sites, I am now using a wildcard SSL certificate for all blogs. I would like all old http-URL's to be 301 redirected to the new https-URL's. What is the best way for me to do this?

Staff
43,761 Points
2015-02-16 12:45 pm
Hello Zultan,

Have you tried the instructions in this article? Is that working or not working for you? Are you getting any errors or strange behavior?
n/a Points
2015-02-16 1:46 pm

Hi Scott,

 

Thank you for your reply! After more research, I ended up using the following code in my WordPress multisite install's .htaccess:

 

RewriteEngine OnRewriteCond %{HTTPS} !=onRewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R=301,NC,L]

 

This code is working well in redirecting all old http URL's to the new https URL's for all my subdomains.

 

What are your thoughts on this code?

Staff
43,761 Points
2015-02-16 2:57 pm
Hello Zultan,

Yes, that should work well for you. It basically says to take anything with the base domain (including subdomains and subfolders) and send it to https. Please let us know if you have any further questions on the issue, we are happy to take a look.

Kindest Regards,
Scott M
n/a Points
2015-01-15 4:56 pm

How can I force only 2 specific sites to use https on 20 site multisite setup (drupal 7)

I have tried:

#site 1

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

#site 2

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

 

But this is not working...I can still access them using http://www.example1.com

Staff
30,388 Points
2015-01-15 5:51 pm
Hello anakonda,

Thank you for your question about forcing https on a drupal multisite. I spent some time looking into this, and could not find a working example.

I did find a helpful article in the Official Drupal forums titled Multisite SSL Considerations. In that detailed article they explain in-depth some of the issues with using an SSL with multisites, and even state the following:
"If you are using SSL certificates, you are probably selling something online and will make some money. If you are using a cheap hosting account then you can afford to put each Web site on a separate hosting account with a unique IP address and a simple SSL certificate."

Then, you can Enable SSL in Drupal for each individual site.

You may benefit from posting your question in the Drupal Forums since it is frequented by Drupal developers.

I hope this helps,
John-Paul
n/a Points
2015-01-16 6:19 am

Hi johnpaulb-imhs1,

Thank you for your answer. 

I have anyway managed to install SSL certificates on 2 different domains on a Drupal  multisite setup. So that is not a problem, it can be done using virtual hosts blocks. 

So the only problem is related to htaccess file and how to tell only specific sites to redirect to https. I have only seen here instructions how to redirect all the sites to https but in my case I don't want to redirect all domains to https. Only certain domains 

So now I have: 

site1.comsite2.comsite3.comsite4.com 

Which are all using same single htaccess file. 

And site1.com and site2.com should be forced (redirected) to use https but other domains should not. So all the sites are using the same htaccess file because of drupal multisite setup. Anyway in this case Drupal multisite should not be the problem, only thing is how to write the script in htaccess, if it is even possible. 

 

Staff
40,336 Points
2015-01-16 1:01 pm
Hello Anakonda,

This can be accomplished in the .htaccess file using several rewrite rules. Check out 301 permanent re-directs via .htaccess for examples of how a rewrite can be used to change the URL. Basically, if you have a domain that needs to permanently go to a DIFFERENT URL, then you should use a re-direct rule. If you're trying to use the same URL and it simply needs to be changed to be something else like "https://example.com/site1 to http://example.com/site1", then you should use a re-write to change it to the URL that you want to use.

I hope this helps to answer your question, please let us know if you require any further assistance.

Regards,
Arnel C.
n/a Points
2014-12-30 5:18 pm

Hello,  I think this is simple but I can't get it to work:I want all https requests to be forwarded to the www site. For example:

https://example.com should go to https://www.example.com

ALSOall non-www http requests should go to the www site for example

http://example.com should go to http://www.example.com

can you help ?   I need this because my SSL is only on the www version of the site.

Staff
11,186 Points
2014-12-30 5:37 pm
To do so, your rewrite rules would look like this:

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

n/a Points
2014-12-30 6:22 pm

I tried what you suggested but it redirects ALL requests to https.

Staff
11,186 Points
2014-12-30 6:33 pm
I may have misunderstood your question. The code above will indeed redirect all requests.

The following will redirect non-www to the www version and keep HTTP/HTTPS intact:

RewriteCond %{HTTP_HOST} ^www\.
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}$1 [R=301,L]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}$1

n/a Points
2014-12-17 1:55 pm

Many thanks Arnel C. for your fast reply!

n/a Points
2014-12-17 12:55 pm

Hello!

Although my question seems as question from "Yves", as I didn't understand well and as that question was not (right) replied yet, please let me know:When I use a rule to force "all web traffic to use HTTPS" as quoted in this article above, it means that both "www.example.com" and "example.com" (with and without www) are redirected to "https://example.com" if I write rule like this (following the example):

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://example.com/$1 [R,L]Many thanks!
Staff
40,336 Points
2014-12-17 1:38 pm
Hello Helio,

The code forces ALL website traffic to use the specified domain name. Yes, all non-www and URLs with WWW would be forced to use URL that you specify in the rule ("https://example.com" in the example). All website traffic, means any website.

I hope this helps to answer your question, please let us know if you require any further assistance.

Regards,
Arnel C.
n/a Points
2014-12-16 4:19 am

I added the following code on my .htaccess file:

RewriteEngine On

RewriteCond% {80} SERVER_PORT

RewriteRule ^ (. *) $ Https://www.yourdomain.com/$1 [R, L]

But nothing happens when accessing the website, the address remains in http and not https. But when I use the following code:

 

# Redirect all "not correct" domain to www with https

# (Is not significant if comes with or without https):

RewriteCond% {HTTP_HOST}! ^ Www.yourdomain.com $ [NC]

RewriteRule ^ (. *) $ Https://www.yourdomain.com/$1 [L, R = 301]

# Redirect all non-ssl to ssl.

RewriteCond% {HTTPS} off

RewriteRule ^ (. *) $ Https://www.yourdomain.com/$1 [R, L]

yourdomain.com and www.yourdomain.com addresses are forced to https // www.yourdomain.com only for Google Chrome, Internet Explorer, Opera Browser but for for Mozilla Firefox I have an error message:

"This connection is not certified

You have asked Firefox to connect securely to www.yourdomain.com, but we can not confirm that your connection is secure.

Normally, when you try to connect securely, sites will present trusted identification to prove that you are at the right address. However, the identity of this site can not be verified. "

So I don't know how to fix the problem with FireFox. Thank you for your help

Staff
43,761 Points
2014-12-16 9:28 am
Hello Yves,

The error you are getting from Firefox looks to be the 'Untrusted Connection' message. This is normally when you are requesting secure connection to a site that does not have an SSL for that specific URL. Without knowing your domain name, I cannot test anything, but you will want to run an SSL test on the exact URL you are working with to ensure that it is set up correctly. You can do that with this SSL Checker.

Kindest Regards,
Scott M
Staff
43,761 Points
2014-12-15 11:47 am
Hello Yves,

Did you follow the instructions given above? If so, did you get stuck or receive an error of some sort? Please provide as much detail as possible so we can assist you.

Kindest Regards,
Scott M
n/a Points
2014-12-14 10:11 am

hi,

Someone to help me please. I have a website where I installed an SSL certificate So I want

When is accessed www.example.com or example.com >> it is redirected to https://example.com 

or if possible,

www.example.com or example.com goes to https://www.example.com

example.com >> https://www.example.com

 

Thank you very much for that.

n/a Points
2014-12-08 5:44 am

Hello. Please help me. How to 

Force Load Static Files Using HTTPS?

Example

https://autorenta.by 

Links pages not working

Staff
40,336 Points
2014-12-08 11:46 am
Hello Lev,

Thanks for the question. As far as I can tell, the links are working on your URL. I couldn't find one that wasn't working. Please provide us more information on the URL that isn't working and we can look further into it. When you are referring to forcing the load of STATIC pages, it's generally in reference to caching. You may want to review the discussions in this forum post in regards to this issue.

I hope this helps to answer your question, please let us know if you require any further assistance.

Regards,
Arnel C.
n/a Points
2014-12-06 11:21 am

Thank You very much it works for me Thank You

n/a Points
2014-12-05 10:31 am

Hi, I have a wordpress site and I want to redirect to https all traffic beside the folder "files", I tried a lot of combinations, In wordpress settings I input https://www.mysite.com, I hope is correct. If I add this rule to .htaccess is all ok

RewriteEngine On

RewriteCond %{HTTPS} off

RewriteCond %{REQUEST_URI} !^/files/? [NC]

RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=302,L]

mysite.com became https://www.mysite.com

http://mysite.com became https://www.mysite.com

www.mysite.com became https://www.mysite.com

But www.mysite.com/anypage remain www.mysite.com/anypage

Staff
10,077 Points
2014-12-05 11:18 am
Hello Gigi Duru,

Below is a .htaccess code that should work for what you are looking for:

RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} ^/files
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Kindest Regards,
TJ Edens
n/a Points
2014-12-05 11:28 am

It's worst now

www.mysite.com remain www.mysite.com

www.mysite.com/anypage remain www.mysite.com/anypage

Staff
10,077 Points
2014-12-05 11:49 am
Hello Gigi Duru,

That is strange as it worked for mine, lets try this one:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/files
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Kindest Regards,
TJ Edens
n/a Points
2014-12-05 12:01 pm

This will fix only homepage but

www.mysite.com/anypage remain www.mysite.com/anypage

I found an alternative by installing Force SSL plugin in wordpress and leave "files" folder without .htaccess file

n/a Points
2015-08-14 10:48 am

I have been having the same issue and trying to fix it for longtime. When I try any of the codes provided above, the website doesn't load. The website is built using wordpress. I am trying to have all pages viwed using https so when customers use their credit card to pay, then it doesn't show the warning note that the age is unsecured. I tried some of the codes and pasted them in .htaccess file but didn't work. I want to know if there is a way to resolve this issue. Some one, above, said that they have "I found an alternative by installing Force SSL plugin in wordpress and leave "files" folder without .htaccess file". I did install the Force SSL plugin, but I am not understanding what they mean by "leave "files" folder without .htaccess file"

Staff
30,388 Points
2015-08-31 10:56 am
Hello Mo,

Thank you for contacting us. WordPress (along with its themes/plugins) also adds rules to your .htaccess file. This can cause issues when you add additional rules to your .htaccess file.

Since you are using WordPress, you must change the WordPress & Site Address to include https (instead of http). This is covered in our full guide How to Enable https (SSL) in WordPress.

If your problems persist, review your existing .htaccess rules for one that may be interfering with this redirect. We also have a helpful Common WordPress Troubleshooting Techniques guide.

Thank you,
John-Paul
n/a Points
2014-10-20 1:56 am

Hi,

I have been having problem with the force ssl issue in our Joomla website. All i did was to enable force ssl in the configuration.php. I tried this first in our server and it worked totally fine. I implemented it to the live server for this website and it just say that the "This webpage has a redirect loop". I only need to do the force ssl on the administrator page. I have tried different solutions that i have found on the internet but still got nowhere to fix this issue. I will be grateful if you guys could help me.

Thanks!

Staff
43,761 Points
2014-10-20 1:24 pm
Hello Jason,

When you are getting the 'redirect loop' error, it means that there are conflicting redirects in your htaccess file. You will want to check that and remove the one you do not want. This should allow your site to redirect properly.

Kindest Regards,
Scott M
n/a Points
2014-10-01 5:50 am

How does your SSL certificate look like? Is there a green bar? A lock? Just an "https" ?

Why is there only one option (US$ 100 per year)?

Thanks

Staff
43,761 Points
2014-10-01 9:28 am
Hello Julien,

As your question does not relate to forcing SSL via the htaccess file, it has been moved and created as a new question found here.
Questions about purchasing an SSL.

Whenever you have a question not related to the article topic, please create a new question so that others can find it more readily and help you.

Kindest Regards,
Scott M
n/a Points
2014-08-23 10:49 pm

The Http url dont seem to map to their http counterparts.

for example http://www.example.com/uk/cameras goes to https://www.example.com/uk

here uk being a sub domain (store).

The root folder has an htaccess file and so does the sub domain

I've tried using the fix listed here but it doesnt work, am i missing something.

 

Staff
11,186 Points
2014-08-25 10:54 am
The code example in this article should work perfectly, but your individual circumstances can cause issues. Could you clarify exactly how your site is built? Certain content management systems and carts can cause issues with redirects. Could you also provide me with what is in your .htaccess file?
n/a Points
2014-08-08 2:39 pm

Hey guys,

I am trying to do two things here. I want to force non www. on all of my pages, but I also want to use SSL on the shoppig cart, payment and account pages. WHen I forced non www it removes the https on those pages.. How do I write this?

 

Thanks!

Staff
30,388 Points
2014-08-08 4:38 pm
Hello Gorilla,

Thank you for contacting us. Usually, the easiest way is to force SSL on the whole site without the www.

We are happy to assist you further, but will need some additional information.

Can you provide the full .htaccess rules you are using?

Are you using a CMS such as Wordpress, Joomla, Concrete5? What 3rd party addons/extensions are you using? This is important to know, since they often use their own rules.

If you have any further questions, feel free to post them below.
Thank you,

-John-Paul
n/a Points
2014-04-16 5:22 pm

Hi Scott,

I am trying to force all non https traffric to use https. The problem that I am having is that the various page urls are dynamic and although my redirect work for the domain it seems to ingore everything after the .com portion of the url. Any thoughts on how to solve would be appreciated.

Thanks,

Rod

Staff
40,336 Points
2014-04-16 6:41 pm
Hello Rod,

Thanks for the question! If you need to force EVERYTHING to HTTPS, put this rewrite rule as your first rule. Remove any of the older rules that you may have added to make it do the same thing.

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

The first condition checks to see if HTTPS is already being used and the second statement re-writes the URL to be HTTPS while maintaining the rest of the URL. Let us know if you have any further questions.

Regards,
Arnel C.
n/a Points
2014-04-14 10:00 pm

I'm not seeing in this thread, re: SSL and redirects, exactly what I'm needing to do for the .htaccess redirects I need.  I have a form in my Wordpress site that I want to make secure behind SSL.  It would be something like: https://www.mydomain.com/myform/

myform is a Wordpress page that contains a form.  This code below doesn't exactly do what I need and I'm hoping someone here can help me sort out what I'm doing wrong.

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

Any clues to help me get this simple thing working?  I've never done SSL before so I am clueless.

Thank you!

Staff
11,186 Points
2014-04-15 9:12 am
You may easily redirect the form using something like the following:


RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^myform$ https://www.example.com/myform [R=301,L]

Staff
43,761 Points
2014-03-19 4:55 pm
Hello MattH,

You may want to try and remove the following 3 lines from your WordPress section and place them above it.:
RewriteCond %{SERVER_PORT} 443
RewriteRule ^(.*)$ http://www.boostyoureco.org/$1 [R,L]
RewriteRule ^index\.php$ - [L]

Next, take the rewrite rules and combine them together like so:
RewriteRule ^(.*)$ http://www.boostyoureco.org/index\.php [R,L]

So before the Wordpress section, you should have the following lines:
RewriteCond %{SERVER_PORT} 443
RewriteRule ^(.*)$ http://www.boostyoureco.org/index\.php [R,L]

That should allow your site to process the link and force the standard version for anything coming in on the https port (443).

Kindest Regards,
Scott M
n/a Points
2014-03-19 1:44 pm

I was wondering how to enforce non-SSL, our site used to be https, switched hosting to inmotion and dont need the secure connection anymore. We now have a bunch of external links from social media sites going to https://boostyoureco.org and being denied connection. It is a wordpress site and have tried many variations of .htaccess rewrite rules with no avail. I even tried https://wordpress.org/plugins/force-non-ssl/ but that did not work aswell.

The last try at the .htacess file:

# BEGIN WordPress

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteBase /

RewriteCond %{SERVER_PORT} 443 

RewriteRule ^(.*)$ http://www.boostyoureco.org/$1 [R,L]

RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]

</IfModule>

 

# END WordPress

 

Staff
11,186 Points
2014-02-13 9:01 am
Hello rurede2day,

This is because of Joomla's rewrites that are used to make "pretty URLs". Basically, it is redirecting but the content within Joomla is causing it to redirect back to the URL that was previously defined by Joomla.
2014-02-10 4:02 pm
Thanks Scott - It's redirecting use htaccess, but I'm getting a redirect loop error. This is on a Joomla site, could there conflicts with the default Joomla htaccess? Any suggestions.
Staff
43,761 Points
2014-01-13 11:11 am
Hello rurede2day,

There are two ways to force SSL on a specific file. If using a php file, you can add code to the beginning of that particular file as below:
if (!isset($_SERVER['HTTPS']) || !$_SERVER['HTTPS']) { // if request is not secure, redirect to secure url
$url = 'https://' . $_SERVER['HTTP_HOST']
. $_SERVER['REQUEST_URI'];

header('Location: ' . $url);
exit;
}


Or you can use code in the .htaccess file that specifically addresses that file:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} folder/file.html
RewriteRule ^(.*)$ https://www.example.com/folder/file.html$1 [R,L]


The second is likely the easiest, especially if you are using html files and do not have it set to run php code.
Either of these should cause that specific file to run the https protocol.

Kindest Regards,
Scott M
2014-01-10 2:28 pm
What if you want to force SSL on a specific file or files - ie. https://www.yourdomain.com/folder/file.html
5,889 Points
2013-05-03 9:45 am
The 301 is a Permanent redirect and the other is not.

Best regards,
James R

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.

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