How To Force HTTPS Using The
How To Force HTTPS Using The
Contact Support:
SUPPORT CHAT SKYPE 888.321.HOST(4678)
How may we help? SEARCH
How to force HTTPS using the .htaccess file Support Center Login
Written by TJ Edens Views: 354,546 Published: Apr 21, 2016 Comments: 122
Username Username
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
Password Password
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. Remember Me
Forcing visitors to use SSL can be accomplished through your .htaccess file using mod_rewrite. If you’d like more LOG IN
information on mod_rewrite please read our article.
Create an account
If you are using the Premium Website Builder and need to force your website traffic over SSL, please see the Forgot your username?
following article instead: Forgot your password?
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.
Social Media Login
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.
Related Questions
To force a specific domain to use HTTPS, use the following lines of code in the .htaccess file in your website's root
Here are a few questions related to
folder: this article that our customers have
asked:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com [NC] Ooops! It looks like there are no
RewriteCond %{SERVER_PORT} 80 questions about this page.
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
Would you like to ask a question
Make sure to replace example\.com with the domain name you're trying force to https. Additionally, you need to replace
about this page? If so, click the
www.example.com with your actual domain name. button below!
If you want to force SSL on a specific folder you can insert the code below into a .htaccess file placed in that specific
ASK A QUESTION
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.
Like 11 4
Tweet
Hi 20151230 9:16 pm
victor
Reply
Hello Victor, 20151231 10:38 am
Your SSL would still need to be for the domain, but then the code would be exactly
the tutorial displays above for the folders:
Arn
RewriteEngine On
Staff RewriteCond %{SERVER_PORT} 80
37,133 Points 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.
Reply
Thanks, nice somple howto. 20160120 1:13 pm
Reply
David
n/a Points
Is there a way to force SSL on a single post in wordpress via the 20160218 2:46 pm
.htaccess codes above? Thanks!
Reply
Joe
n/a Points
Hello Joe, 20160218 6:52 pm
JohnPaul
Thank you for contacting us. Since you are using WordPress (which also relies on
Staff .htaccess rules), I recommend using a plugin instead of adding a .htaccess rule
27,787 Points directly.
This is to avoid a rule interfering with the functionality of your website.
Thank you,
JohnPaul
Reply
when i add the above code the site going down . 20160401 9:03 am
thanks
Reply
faiz
n/a Points
Hello faiz, 20160509 10:49 am
JohnPaul
Thank you for contacting us. If you are using a CMS (such as WordPress, Joomla,
Staff Drupal, etc.) I recommend using a Plugin, or module to avoid conflicts.
27,787 Points
Are you getting any error messages?
Best Regards,
JohnPaul
Reply
This is the coding I had in my .htaccess file: 20160419 10:15 pm
##### RewriteEngine enabled BEGINRewriteEngine On#####
RewriteEngine enabled ENDRewriteCond %{HTTP_HOST} ^mydomainname\.com
[NC]RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$
Jim Parker https://www.mydomainname.com/$1 [R,L]And this is what was displayed in the browser
n/a Points
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.
Reply
Hello Jim, 20160420 9:28 am
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
scott b) set up correctly.
Staff Kindest Regards,
42,822 Points Scott M
Reply
Hi, 20160509 5:41 am
my host is Siteground and the it wrote me this code that write in
htaccess
Sergio Pinna RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$
n/a Points https://www.sergiopinna.it/$1 [R,L]
And it works perfect.
Reply
This approach is better, automatically gets your URI: 20160509 8:26 am
===================================
RewriteEngine On
Jake RewriteCond %{HTTPS} off
n/a Points
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
Reply
brilliant!!! this the most simple solution I've seen. Any advice 20160923 7:30 pm
as to how search engines will look at this?
Reply
greg
n/a Points
htconfig files exicute serverside, then send the "final 20161228 5:55 pm
product" to the client; so, Search Engines will index the
final URI. So if your htaccess says your home page is https://mysite.com,
then it is so. The caviot is that if you write an internal link to
Jason http://mysite.com and Google ends up at https://mysite.com then it will be
n/a Points aware that it was redirected; so, you must be careful about how you handle it.
Generally, search engines don't care about protocol redirects, but if you use
your htaccess file to redirect to a new domain, such as http://mysite.com to
http://anothersite.com, expect to get flaged.
Lastly, if you want to use it to redirect between internal pages where you want
to change your URL, but keep all of your SEO goodness that has already
been indexed, such as http://mysite.com/wordpress to
http://mysite.com/blog, make sure to use a 301 or 302 redirect.
Reply
add [R=301,L] to the end of the last line; it's sets the redirect 20170212 11:56 pm
to Permanent (for Google and/or for my momcuz I moved
out of her bsmt for good.)
Reply
mind wedgie
n/a Points
Yes it did perfectly worked for me.... Thanks a lot .... I was after this 20160511 9:19 pm
solution for about two days....
Reply
Prince Daniel
n/a Points
Hi, 20160525 4:14 am
I want to redirect url without www to https://www using .htaccess or
any. Please support me . It' s urgent.
rajesh Thanks.
n/a Points
Reply
Hello Rajesh, 20160525 7:14 am
Thanks for the question about redirecting without using WWW in the URL. Your
question is a little confusing because you use "www" in the HTTPS url that you
Arn indicate. However, you can use the tutorial above by simply changing the rewrite to
rewrite to the https:// with no WWW in the URL. The condition for the change would
Staff indicate the WWW version of the URL.
37,133 Points
I hope this helps to answer your question, please let us know if you require any
further assistance.
Regards,
Arnel C.
Reply
As I just mentioned above.... this will solve all of your issues 20160625 9:43 am
and automtically add www. if your domain is set up that way.
In your .htaccess, add:
Jake Newman RewriteEngine On
n/a Points
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
Reply
This code does NOT add www. 20170313 7:53 pm
Reply
zylstra
n/a Points
What about domains that don't use "www". Actually, I need ssl for 20160527 4:05 pm
both the "www" and the nonwww versions of my site.
Should I add anything more to the code?
Steve Reply
n/a Points
Hello Steve, 20160528 12:08 am
You should not have to add anything as long as your SSL is setup for the www
TJEdens
Staff version and nonwww version.
10,077 Points
Best Regards,
TJ Edens
Reply
Hi, 20160528 8:00 am
My website has minor problem only home page doesnt redirect to
https but all other pages does redirects to https.
Max If I click on any other page and then go back to home page then it stays on https. can you
n/a Points please help.
below is the code in my .htaccess file
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ https://www.eastrologer.com/$1 [L,R=301,NC]
RewriteBase /astro/
RewriteRule ^index\.php$ [L]
RewriteCond %{REQUEST_FILENAME} !f
RewriteCond %{REQUEST_FILENAME} !d
RewriteRule . /astro/index.php [L]
</IfModule>
# END WordPress
Reply
I see your site is a WordPress site. Did you set the Home and 20160531 9:18 am
Site URLs to use HTTPS?
Reply
scott
Staff
42,822 Points
I have...wild card SSL 20160528 12:33 pm
1. wildcard SSL for site xyz.com
2. hosted wordpress on subdomain abc.xyz.com
Asiya Amin
but when I enable https on wordpress abc.xyz.com from General Settings (dashboard) and
n/a Points
access the https://abc.xyz.com it redirects to https://xyz.com
Could you please help
Thanks
Reply
You may want to try a more generic code like the one below: 20160531 9:20 am
RewriteEngine On
RewriteCond %{HTTPS} off
scott RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Reply
Staff
42,822 Points
Please clear me that how your code is different from below code 20160530 2:29 am
(Jake mentioned too). What are the implications of using your code
and below code?
Tilak RewriteEngine On
n/a Points RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=30
1]
Thanks!
Reply
Our code is just one way to force the https. Glancing at the 20160531 9:20 am
code you have, it appears it may do the same thing. You can
use whichever one works best for you.
Reply
scott
Staff
42,822 Points
Hello!Thank you for that, quite simple.But, if I try to access 20160608 4:15 am
"domain.com/folder/page", works perfectly. But if I try with the prefix
"www.domain.com/folder/page", my browser say it's an insecure connection.Would you
have any hints on that?Thank's!
Lucas Vilas
Reply
Boas
n/a Points
Hello Lucas, 20160608 6:28 am
Have you checked your pages source code to check what content is not being loaded
TJEdens
Staff via https://?
10,077 Points
Best Regards,
TJ Edens
Reply
Hello i have the following error https://www.*****.co.za " when i place 20160609 2:59 am
this code
RewriteEngine On
Tlou RewriteCond %{SERVER_PORT} 80
n/a Points RewriteRule ^(.*)$ https://www.isolarsolutions.co.za/$1 [R,L]
if i try to access my admin i get the error below
Not Found
The requested URL /wpadmin/ was not found on this server.
Apache Server at ******.co.za Port 443
The website is made from wordpress
Thanks
Reply
Since you are using WordPress (which relies on .htaccess 20160609 1:35 pm
JohnPaul rules), manually adding rules can cause issues.
Staff Instead, I recommend forcing https in WordPress. This is covered in our full article
27,787 Points How to Enable https (SSL) in WordPress.
Thank you,
JohnPaul
Reply
Over the past month I have installed five SSLs on five sites. And this 20160629 6:23 pm
htaccess code has not worked on one. Not one. (All are WordPress
sites.)
I had to trouble shoot each site and each site had a different solution.
steve
n/a Points I don't want to hashout what did and didn't work here. I could really care less. (Really, it is
too frustrating.)
But I DID FIND A WAY THAT SEEMS TO WORK FOR WordPress. I just installed a sixth
SSL. Instead of all the plugin/htaccess mess I just went into phpmyadmin and changed the
site URL and home URL from http://mysite.com to https://mysite.com.
This appears to have done the trick. Is there anything wrong with doing this?
Thanks.
Reply
Hello Steve, 20160629 7:14 pm
The method you used is what was needed to enable SSLs for WordPress. We have
a tutorial for WordPress HTTPS here. If you have any further questions, please let
Arn us know.
Staff Kindest regards,
37,133 Points Arnel C.
Reply
Why not use Server Name parameter ? this way you can copy and
paste it to all the website's you need. Or even put it as a global rule 20160704 11:00 am
for apache.
Koen Hendriks RewriteCond %{SERVER_PORT} ^80$RewriteRule ^(.*)$ https://%
n/a Points {SERVER_NAME}%{REQUEST_URI} [L,R]
Reply
How would you exclude certain paths? Some Magento extensions do 20160706 9:28 am
not work well with forced SSL in the admin area. Thanks in advance!
Reply
alex
n/a Points
Hello Alex, 20160707 6:35 am
We don't really have a tutorial about that ourselves, but you can find regular
expression tutorials through search that discuss it. Here's one that may help.
Arn
If you have any further questions, please let us know.
Staff
37,133 Points Kindest regards,
Arnel C.
Reply
This does not work. I have some pages that go to https and other that 20160728 3:18 pm
go to http. After hours with inmotion hosting they told me that I have
to hard all my web pages, which is silly and I am confident is wrong. I mean why use this in
that case? Maybe they should have qualified the statement that this will only work if you
Asela hard code it, whatever that means. So I hard coded (meaning put https to all the links)
n/a Points some of the pages to test their theory and what they say does not work. I suspect the SSL
has been badly configured by inmotion which make mistakes like the time i asked for TLS
1.2 and they said they do not offer it. But after pushing them for a while I discovered they
do indeed offer it in upgraded server. This is why proper training and knowledge is
important.
Reply
Hello Asela, 20160728 4:37 pm
JohnPaul
Thank you for contacting us. Sorry to hear you are having issues forcing https on
Staff your website. I first checked your SSL with an SSL Checker tool, and it is installed
27,787 Points correctly. Since we now know the SSL is not badly configured, we can rule this out.
TLS 1.2 has been available on our shared servers since December 2015, it was
available on VPS/Dedicated servers before since you have the ability to change your
server settings. If you asked for TLS 1.2 on shared servers prior to December 2015,
it may not have been available yet.
When I test your site, the example.com redirects to https://www.example.com, which
seems to be correct. But, when I check the links in your site menu, many are
pointing to http URL's instead of https. For example:
Home, all of the products (such as Tea, Powder, etc.), all of the "Benefits" links,
Blog, and Cart.
So, while it may force SSL on the main domain, these links seem to navigate visitors
back to http (non SSL) pages.
Also, for a page to be secure, everything being called on the page must be from an
https address. When I reviewed your site, many files are being called in insecurely.
You can view these by reviewing your site on whynopadlock.com, which is a free
tool.
If you suspect the redirect rules are not working, I recommend reviewing the other
rules in the .htaccess file as one may be interfering. You can also troubleshoot the
.htaccess by renaming it, for example to .htaccess.old
Thank you,
JohnPaul
Reply
Hello JohnPaul, 20160729 3:11 pm
Thanks for that well thought out reply. Whynpadlock
was very useful to test. Thank you. The TLS 1.2 I had requested this year, so
be aware some of your reps don't have perfect knowledge. Of course what
Asela this shows is that forcing into https does not alwasy work. At the end of the
n/a Points
day you have to hard code all the links.
But I appreciate your reply which has improved my confidence in inmrtion
hosting. Thank you.
Reply
Just installed SSl on my domain. To force all web traffic to use SSL, Where do i add this code: 20160729 7:52 pm
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]My current htaccess looks like like this...# BEGIN WordPress
simon <IfModule mod_rewrite.c>
n/a Points RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ [L]
RewriteCond %{REQUEST_FILENAME} !f
RewriteCond %{REQUEST_FILENAME} !d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Reply
WordPress relies on .htaccess rules, which can cause issues 20160801 10:55 am
JohnPaul when you add code directly to your .htaccess file as described
in the guide above.
Staff
27,787 Points Since it seems you are using WordPress, you should enable HTTPS (SSL) in
WordPress.
Thank you,
JohnPaul
Reply
Hi, I want to redirect http to https only for home page not all other 20160804 8:13 am
pages.Please advise me.
Thanks
priya Reply
n/a Points
Here is a link to an online post I found via search engine, where 20160804 4:00 pm
JohnPaul they discuss possible solutions.
Staff Thank you,
27,787 Points JohnPaul
Reply
Hi 20160805 7:10 am
i have a problem with my 301 redirects. I have 1 going from non www
to www and http to https. So far so good. If I go non https version of home page either
www or non www it directs to https://www as it should. It go to the non https of a page it
Tim doesn't redirect.
n/a Points
Reply
I advise commenting out other rules to see if they might be 20160805 7:42 am
having an affect on the rewrite rules.
Reply
christopherm
Staff
7,709 Points
You should change the code to R=301 so it becomes a 301 redirect. 20160809 3:27 pm
This will preserve people's backlinks and rankings in google.
Paul House RewriteEngine On
n/a Points RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
Reply
Hi, i want to force https for my subdomain, where do i need to place 20160811 4:51 am
above code? it is in root or htaccess in subdomain folder? i have try
both, but didn't work. When i place this code my page cannot be open and dislay this
Typically, you would put it in the document root of your 20160811 11:24 am
JohnPaul subdomain.
Staff Keep in mind if you are using a CMS (such as WordPress, Joomla, Drupal, etc.) that
27,787 Points they also rely on .htaccess redirect rules, and we recommend changing the setting in
the dashboard instead of forcing it directly in the .htaccess file.
Thank you,
JohnPaul
Reply
Great tutorial. 20160813 7:25 pm
Work perfect on website.
RewriteEngine On
Tize RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
n/a Points
Reply
iam usin this code 20160814 4:30 pm
RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$
https://mydomin.com/$1 [R,L]
aalimd
n/a Points
and when i go to my domain this message appear
The domain.com page isn’t working
domain.com redirected you too many times. can u help me on that please
Reply
What is your actual domain name? 20160815 8:43 am
Reply
Tim S
Staff
12,676 Points
this is my domain name 20160815 10:30 am
****.com
****.com/xf
aalimd and i removed the htaccess for ***.com
n/a Points
Reply
The code below should work fine: 20160815 3:26 pm
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
scott
You can also try:
Staff RewriteEngine On
42,822 Points RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
Be sure it is up at the top of your .htaccess file.
Kindest Regards,
Scott M
Reply
in first "example.com" you need to replace it with your full domain 20160820 10:30 am
like this www.example.com in this way it worked for me.
Reply
john
n/a Points
I have a blog installed in a subdirectory with no SSL. 20160824 10:59 am
In the root directory we have another WordPress installation which is
membership based and has SSL.
Torkild Sometimes the blog switch over to HTTPS and the blog's CSS goes missing.
n/a Points
Is there a way to reverse this, i.e. force the blog to display http:// instead of https:// ?
Thanks
Torkild
Reply
Hello Torkild, 20160824 11:04 am
You can use the last code provided in the tutorial above and change it to use HTTP
instead of HTTPS.
Arn
If you have any further questions or comments, please let us know.
Staff
37,133 Points Regards,
Arnel C.
Reply
If I use this in my .htaccess it tells me either that the page doesn't 20160904 8:45 am
work because it redirected me too many times or it gives me an
internal server error
Reply
Maxime
n/a Points
It's possible the file may be conflicting with rules in another 20160906 12:28 pm
.htaccess file in the same directory or nested elsewhere.
Reply
christopherm
Staff
7,709 Points
Hello Joshua, 20160908 8:20 am
Thanks for the question about forcing the SSL on your other pages. You should first make
sure to follow the tutorial above. You should also go to any links that reference your other
Arn pages and make sure that they are using HTTPS. The rewrite rule above should work for
any domain or subdomain that has been covered by the SSL certificate. However, if you
Staff intend to keep all of your pages to use SSL, then your page links should using the SSL link
37,133 Points and not HTTP.
I hope this helps to answer your question, please let us know if you require any further
assistance.
Regards,
Arnel C.
Reply
Hey! 20160909 2:06 pm
I used your code for my website ans when I open it in the browser it
shows me: ERR_TOO_MANY_REDIRECTS
Simon Reply
n/a Points
It is possible there are other .htaccess files that are affecting 20160909 2:25 pm
each other. I advise checking your Home directory.
Reply
christopherm
Staff
7,709 Points
Please help me. After installing latest SSL in my website, i found out 20160909 6:00 pm
that old browsers can not access my website, though i have added
this(RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^/?(.*) https://%
{SERVER_NAME}/$1 [R,L] ) to force my site to https. So since because of that old browser
udoka issue, i want to make only my index.php page to beecome http so that i can notify my
n/a Points users to upgrade there browser before going to another page. please i need help.
Reply
You can redirect https to a specific folder you would like to 20160909 6:23 pm
secure, like "example.com/store" or "/secure", following the
final steps of the article above. Use the code from the last example.
Reply
christopherm
Staff
7,709 Points
I installed SSL on my domain and changed http to https.now what my 20160914 4:27 am
problem is if i want to view a page with
http://mydomain.name/page.html it redirects to homepage.but
https://mydomain.name/page.html means it shows correctly
Akilan
Reply
n/a Points
Hello Akilan, 20160914 3:18 pm
If your linkings are FORCING you to go to HTTPS, then HTTP may not be available.
Make sure that your links are not forcing you to use HTTPS, then you should be
Arn able to use the nonHTTPS urls to access your site. Redirects are found within the
.htaccess file. Check this file to see if you have any redirects/rewrite rules that are
Staff affecting how you get to your HTTP URL.
37,133 Points
If you have any further questions or comments, please let us know.
Regards,
Arnel C.
Reply
Hi I too need a force SSL option on my website via .htaccess. What 20160915 2:07 pm
will I need to redirect all http pages/posts to their https counterparts
using a 301 redirect? I would like to pass the "link juice" along to the https version so it isn't
lost. Thanks.
Tyler
Reply
n/a Points
Google should not penalize you for using 301 redirects to 20160915 2:28 pm
JohnPaul redirect your traffic.
Thank you,
JohnPaul
Reply
Working prefect for my domain: jodyshop.com
Working prefect for my domain: jodyshop.com
20160916 11:39 am
Thank you
Reply
misron5
3 Points
Wow! It works! YES... so easy, so simple. Thank you... Finally SSL 20160918 10:46 am
without errors
domain.com to https://www.domain.com
www.domain.com to https://www.domain.com
Goro https://domain.com to https://www.domain.com
n/a Points
domain.com/file.jpg to https://www.domain.com/file.jpg
Reply
How can I install it in a subdomain 20160928 9:46 am
Reply
Daniel
n/a Points
Hello Daniel, 20160928 11:31 am
You simply need to add the subdomain into the URL in the rule. This is not an
"installation".
Arn
For example:
Staff
37,133 Points 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.
Reply
Hello, 20161006 8:06 am
I have many pages that I would like to redirect to a new domain in a
htts://www. version of my website. Could you please tell me the .htaccess code for each
one of them?
Andreas
n/a Points conditions :
if http://www.example.co.uk/page1
or http://example.co.uk/page1
or https://www.example.co.uk/page1
or https://example.co.uk/page1
redirect (301) to
https://www.example.com/page1
Your reply with the code will be used many times, for each one of these pages (page1,
page2, page3 etc)
Thanks in advance
Reply
Hello Andreas, 20161006 9:50 am
JohnPaul
Thank you for contacting us. We do not provide custom solutions, but you should be
Staff able to accomplish this by adjusting the examples above.
27,787 Points
Thank you,
JohnPaul
Reply
Hi I want to remove the folder name from URL access. How to 20161013 4:26 am
achieve that?
Reply
Vinoth
n/a Points
Hello Vinoth, 20161013 10:19 am
You would need to use a Rewrite rule. This will rewrite the URL so that they see only
what you want them to see.
Arn
If you have any further questions or comments, please let us know.
Staff
37,133 Points Regards,
Arnel C.
Reply
So i have ssl on a .co domain name and i also have a http .com 20161020 1:50 pm
domain that redirects to the https .co domain, if someone should put
the https infront the .com domain, it will give a security error, anyway to fix or adjust that?
Howard
n/a Points Howard
Reply
The easiest way to fix this is to install an ssl for the .com 20161020 5:12 pm
JohnPaul domain.
Staff Thank you,
27,787 Points JohnPaul
Reply
Hi,I want to redirect https://www.example.com/notice to ( my 20161027 6:45 am
another server )https://info.example.com/noticeBoth have SSL
installed, https://www.example.com is wordpress site.what should i write to .htaccess ? i
have several redirection same way, please helpThanks
Munna
Reply
n/a Points
Since you are using WordPress which also relies on .htaccess 20161027 10:21 am
JohnPaul rules I recommend using a "301 redirect" plugin. This will
reduce the chances of a rule interfering the the functionality of your site.
Staff
27,787 Points
If you are determined to hand code this, it is covered in our guide on setting up a
permanent 301 redirect via .htaccess.
Thank you,
JohnPaul
Reply
Thank you this post my website is working now.. i use this code 20161110 10:17 am
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
this one will replace all your links to https
bladerxjun
3 Points Reply
Hi, some really useful examples here. Could you please help me out? 20161118 8:19 am
I have a website and the customer wants everything to redirect to
example.com/en/ by default.
Is there a single rule that will forward, http:// and http://www to
Adam Parrish
https://www.example.com/en/ ?
n/a Points
I am asking for a single rule as my understanding is the fewer redirects the better for
Google? Thank you!Adam
Reply
Adam, you should be able to use the following: 20161118 10:49 am
RewriteEngine on
caseyb RewriteCond %{HTTP_HOST} ^fromcrimsontowool\.com [OR]
Staff RewriteCond %{REQUEST_URI} !^/en
2,160 Points RewriteRule ^(.*)$ https://www.fromcrimsontowool.com/en/$1 [L,R=301,NC]
Reply
Thanks so much for your reply. However I just get an 20161125 9:04 am
error when I use your code.
Adam Parrish This is what I have that works, I just want to combine it into a single redirect:
n/a Points
# 301 to www
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain.com
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]
# 301 to https
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Thanks.
Reply
I am forcing https as above without issue. However, some 20161118 11:46 pm
subdirectories have .htaccess files that use authorization via
AuthType Basic. The authorization is happening prerewrite (in the clear, http). Is there a
way to rewrite to https before authentication therefore securing the transfer of the user/pw
Mark@ss within the https context?
n/a Points Reply
htaccess files are processed topdown. Do you get a better 20161121 4:59 pm
response by rearranging the order of the codes?
Reply
scott
Staff
42,822 Points
Hello! 20161122 6:13 am
We recently purchased SSL certificate for our website. We currently
have 2 redirects
Sahil For eg:
n/a Points Original URL http://www.example.com
Now after purchasing SSL:
https://www.example.com
How do I redirect users accessing HTTP version of the website to HTTPS WWW version of
the website?
Currently I have 2 redirects HTTP > HTTPS and then HTTPS > WWW as our website is
using www preferred version.
My question is can I directly setup HTTP to HTTPS WWW redirect?
Kindly help
Thanks!
Reply
You will want to make sure that you redirect to the domain that 20161122 9:50 am
is on the certificate, whether it is www or nonwww.
Reply
christopherm
Staff
7,709 Points
I am trying to use an MVC approach in my site programming, that has 20161129 3:03 pm
one entry file index.php. How would I redirect to https with this
approach? This is what I have in my .htaccess file right now:
RewriteEngine on
Yaroslaw RewriteBase /
n/a Points RewriteCond %{REQUEST_FILENAME} !f
RewriteCond %{REQUEST_FILENAME} !d
RewriteRule ^(.*)$ index.php
Reply
If you place the https redirect code above the code sample 20161129 6:12 pm
you provided you should not have any trouble.
Reply
christopherm
Staff
7,709 Points
Thanks Brother.. I just loved it, cause it worked. Thank you so
Thanks Brother.. I just loved it, cause it worked. Thank you so
20161130 2:54 am
much...
Reply
Sultan
Mahmud
n/a Points
I love it: simple, elegant, and it worked perfectly for my site. 20161201 10:25 am
Thanks!
Reply
Herb
n/a Points
# BEGIN WordPress 20161215 2:38 am
<IfModule mod_rewrite.c>
RewriteEngine On
saleem khan RewriteCond %{SERVER_PORT} 80
n/a Points
RewriteCond %{REQUEST_URI} folder
RewriteRule ^(.*)$ https://www.****.co.uk/folder/$1 [R,L]
RewriteBase /
RewriteRule ^index\.php$ [L]
RewriteCond %{REQUEST_FILENAME} !f
RewriteCond %{REQUEST_FILENAME} !d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Thank you
I am using the above code and its working well but when i open my wp admin panel then its
redirect to the home page and i couln't reach my dashboard so plz help me.
Reply
Since WordPress relies on .htaccess rules, we do not 20161215 10:33 am
JohnPaul recommend adding code directly to the file.
Staff Instead, you should enable SSL in your WordPress Site URL. This reduces the
27,787 Points chances of a rule interfering with the functionality of WordPress.
Thank you,
JohnPaul
Reply
My website https://www.mywebsite.com, it is static website. and I want to clear 20170104 8:52 am
my all canonical issues. for example if some one
types https://www.mywebsite.com/index.php, https://mywebsite.com/index.php, https://mywebsite.com,
http://www.mywebsite.com/index.php, http://mywebsite.com/index.php, http://mywebsite.com, my only
Naveen one URL should come up or it should show, that is https://www.mywebsite.com. How I need to do?
n/a Points
Reply
You need to force either WWW or nonWWW and force either
HTTPS or HTTP. This can be accomplished via the htaccess 20170104 9:51 am
file.
Reply
Tim S
Staff
12,676 Points
Thank you sOooooOOOoo much, this worked perfectly :) 20170110 6:52 pm
Reply
Sally
n/a Points
I inserted the following code into my .htaccess file on the root 20170118 12:31 am
directory. I placed it at the top lines, above the lines of code that
were already there. Despite doing this, when I type in my website name as gunneria.com
or www.gunneria.com, it goes to www.gunneria.com and not to https://www.gunneria.com.
Tallyho
n/a Points
Any idea what I am doing wrong? Thanks for your help!
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.gunneria.com/$1 [R,L]
Reply
Hello Tallyho, 20170118 11:03 pm
We would need to see what else is in the file in order to assess the issue.
Additionally, make sure that you don't have another .htaccess file that might be
Arn overwriting this one. Please first start that check and let us know if you require any
further assistance.
Staff
37,133 Points If you have any further questions, please let us know.
Kindest regards,
Arnel C.
Reply
Does the code above transfer Page Rank to the HTTPS site too? I 20170124 10:48 am
know I'm supposed to do a 301 redirect, but when I tried to do a 301
on top of this, the page would stop loading due to too many redirects.
Reply
DiggDang
n/a Points
If you are using a CMS like WordPress or Joomla, there are 20170124 2:55 pm
already existing .htaccess rules that can be causing the
conflict. If that is the case, you may want to consider using a plugin to switch to
https. In most cases, a sophisticated search engine should be able to tell it is
christopherm looking at the same site with https instead of http. However, you can adjust your
preferred protocol in something like Google's Webmaster Tools and then wait for
Staff Google to recrawl the site.
7,709 Points Reply
Thanks for your response... I do use Wordpress... I 20170125 2:52 pm
noticed though, that Google started showing me search
results with my new HTTPS URL where my old one used to be, so I hope that
I'm good. I did register the HTTPS account in GWT, as you also advised.
Thanks again!
DiggDang
Reply
n/a Points
I am using OpenCart. I want call URL 20170217 12:26 am
www.mydomain.com/api/common.php.
I added this new line in the .haccess file, but it's not working:
Dao Kien RewriteCond %{REQUEST_URI} !^/(qb|qb/.*)$
n/a Points Please help me.
Thanks
Reply
Dao, as this has to do with making custom changes to the 20170217 10:25 am
coding of your site or sites, it is outside of the scope of
support that we are able to provide. You will want to work with an experienced web
developer, if you don't have one already, to assist you in resolving this. Alternatively,
caseyb
Staff you may wish to have a look at https://code.tutsplus.com/tutorials/theultimateguide
2,160 Points tohtaccessfilesnet4757
Reply
You really made my day, i was pulling my hair out as the ssl was 20170218 1:35 am
installed properly but site was going to http:// instead of https:// and
was showing connection not secure...
After the .htaccess change, everything worked as a charm.
suhail
n/a Points By the way I am usinghost, domain and SSL all provided by godaddy...
Reply
My current .htaccess file currently has the following syntax: 20170221 4:04 pm
# BEGIN WordPress
<IfModule mod_rewrite.c>
Alan RewriteEngine On
n/a Points
RewriteBase /
RewriteRule ^index\.php$ [L]
RewriteCond %{REQUEST_FILENAME} !f
RewriteCond %{REQUEST_FILENAME} !d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I would like to force the domain.com to go to the www.domain.com everytime. I want to add
something like the following to the .htaccess above:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain.com[nc]
RewriteRule ^(.*)$ http://www.domain.com/$1 [r=301,nc]
The problem is that when I add this additional syntax to my .htaccess and then test the
WordPress website, I get an error, "too many rewrite conditions."
Any ideas on how I should include the additional syntax into the existing .htaccess file?
Reply
Alan, the easiest and most effective way to do this as you're 20170221 4:27 pm
using WordPress, is to update your site URL and WordPress
address to use the www for your domain.
caseyb Reply
Staff
2,160 Points
THanks! it worked pretty well! 20170222 11:28 am
thanks!
Esteban
Reply
Fernandez
n/a Points
Great, easytofollow examples, thanks a lot. Have to say I'm pretty 20170307 5:27 am
impressed by the inmotionhosting support pages they're very well
written.
Mark
n/a Points Reply
Hi, 20170310 2:17 am
I have:
Dorian Staten RewriteEngine On
n/a Points
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
in my .htaccess, and all of my pages forward to HTTPS properly except when the URL
includes the page file name.
For instance, http://baytowntalkforum.com redirects to HTTPS, but
http://baytowntalkforum.com/index.php does not. Same with
http://baytowntalkforum.com/games.php, http://baytowntalkforum.com/members.php, etc.
Anytime the page's filename is included, it won't forward. I've searched all over the web and
can't find a fix for this. Can you help, please?
Thanks,
Reply
D, I used your exact code on a brand new site with only three 20170310 4:01 pm
files. A test index.php, a phpinfo.php file, and a .htaccess file
that only had your code in it. My site redirected even if I put a filename at the end.
caseyb This would indicate either a browser caching issue, or an issue with your web hosting
Staff setup. I recommend clearing your browser cache, and trying again.
2,160 Points Reply
Hi Dorian,I use the code below and work great: 20170312 4:51 am
RewriteEngine on #RewriteBase / RewriteCond %{HTTP_HOST}
^www.example.com [NC] RewriteRule (.*) http://example.com/$1 [R=301,L]RewriteCond %
{HTTPS} offRewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]If not
Mirko work remove the part #RewriteBase / .
n/a Points
Check my website for example:gamesunblocked.us.
Try all version in your browser.
Reply
I need help, i forced ssl on all pages of my website but the layout is 20170314 7:13 pm
scattered... any advice?
Reply
ITORO
IHKPESSII
n/a Points
Sounds like some of your resources are loading over HTTP. 20170315 8:27 am
Make sure your CSS, images, and JS all load over HTTPS.
Depending on how your website is built this can be accomplished many ways. If it's
a WordPress website, there's a plugin to force HTTPS which works well.
Tim S Reply
Staff
12,676 Points
Just wanted to say thank you for this post... know it's been up for a 20170315 6:32 pm
while, but for some reason I can't get the htaccess rules to stick in
my head. Use this post to jog my memory more than I am comfortable admitting :/
Reply
Topher
n/a Points
Hi, 20170319 6:37 pm
thanks for putting the time i to monitor this interesting thread.
I am thinking of using this code to redirect login.php to https.
Moman da RewriteCond %{SERVER_PORT} 80RewriteCond %{REQUEST_URI} ^/(login\.php) # Will
roman force SSL on login.phpRewriteRule ^(.*)$ https://www.mywebsite.co.uk/login.php$1 [R,L]
n/a Points
Problem is I have a login.php in www.mywebsite/admin/login.php, will this not redirect my
admin login to the customer login page?
Best fix? I may just have to rename my admin login page if not.
Reply
You may want to put an .htaccess file in the /admin folder with 20170320 1:54 pm
just the redirect code in it. That should govern that specific
file.
Reply
scott
Staff
42,822 Points
Hi 20170404 1:35 pm
I am using the following for SSL
#Rewrite everything to https
Marie RewriteEngine On
n/a Points
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
I now want to change the following url
https://www.website.com/index.php?p=1
to
https://www.website.com/1/
I have tried various options but can't get any of them to work.
Any suggestions?
Many thanks
Reply
Those do not appear to be the correct syntax. I advise copying 20170404 1:47 pm
and pasting one of the above snippets from this article.
Reply
christopherm
Staff
7,709 Points
Post a Comment
Name:
Email
Address:
Comment:
Type the text
Privacy & Terms
Submit Please note: Your name and comment will be displayed, but we will not show your email
address.
SUBMIT COMMENT
Need more Help?
Search Ask the Community!
How may we help? SEARCH Get help with your questions from our community of likeminded hosting
users and InMotion Hosting Staff.
Browse Questions Ask a Question
Current Customers Not a Customer?
Chat: Click to Chat Now Email: [email protected] Get web hosting from a company that is here to help. Sign up today!
Call: 888321HOST (4678) Ticket: Submit a Support Ticket
WEB HOSTING HOSTING FEATURES
Business Hosting SSD Hosting
VPS Hosting Shared cPanel Hosting
Dedicated Servers eCommerce Hosting
Enterprise Hosting Solutions SSH Hosting
Reseller Hosting Ruby Hosting
WordPress Hosting PostgreSQL Hosting
Launch Assist� Cheap Hosting
Managed Hosting Cheap Dedicated Servers
Domain Names Transfer Websites
Web Design Services
HOSTING TOOLS COMMUNITY
WordPress Premier Support �
Joomla Support Center
Drupal Host Affiliate
cPanel Web Hosting Infographics
PrestaShop Los Angeles Hosting
Moodle Green Data Centers
OpenCart Student Web Hosting
BoldGrid *NEW* Partners
ABOUT US
Contact Us
Terms of Service
Privacy Policy
Blog
Guarantee
Testimonials
We're Hiring
Site Map
Press
Stay in touch on