We help IT Professionals succeed at work.
Get Started

htaccess File on Weserver Problem

Last Modified: 2012-05-12
I'm trying to force users onto the secure portion of my site for only specific folders. I have 2 folders, one named "account" and the other "accounts" and whenever someone hits a webpage inside one of those folders I want to force them onto https. I can include it in all the links, but there is no guarantee that someone won’t remove the s from https and refresh the page.

I’ve read in numerous other places that say use a .htaccess file to do it. So that’s what I did but it’s not seeming to work. I created a file in each of the 2 folders on my web server called “.htaccess” with the following code inside of it:

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

Will someone who knows much more about how htaccess files work help me please?! Thank you in advance.
RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteCond %{REQUEST_URI} accounts RewriteRule ^(.*)$ 
https://www.mywebsite.com/accounts/$1 [R,L]

Open in new window

Watch Question
This problem has been solved!
Unlock 1 Answer and 8 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE