Link to home
Start Free TrialLog in
Avatar of trevor1940
trevor1940

asked on

Apache Rewrite HTTP To HTTPS

Hi
This question has 3 parts

1
I'm trying to write a RewriteRule based on Specific Directory as a test only I'm using

 
RewriteEngine On
# This will enable the Rewrite capabilities

RewriteCond %{HTTPS} !=on
# This checks to make sure the connection is not already HTTPS

RewriteRule ^/?secure/(.*) https://%{example.com}/secure/test/area/$1 [R,L]
# This rule will redirect all users who are using any part of /secure/ to the same location but using HTTPS.
# i.e.  http://www.example.com/secure/ to https://www.example.com/secure/
# This means if you dont want to force HTTPS for all directories you can force it for a specific sub-section of the site.

Open in new window


My Test.html is located at

http://example.com/secure/test/area/Test.html

instead of getting
https://example.com/secure/test/area/Test.html

I get
http://secure/test/area/Test.html

Obviously I'm substituting the above for actual url

Can someone tell me what I'm  doing wrong

When I'm confidant this works I'll place the .htaccess  file at the root level

2
Will this redirect links hard coded within a WordPress database

3
There is another Rewrite rule further down the tree is this affected if so can I combine the two?

root .Rewrite HTTP To HTTPS
 |
 |
    Rewrite IE 6 fix
        |
        |
           Turn off  Rewrite IE 6 fix but keep http to https
ASKER CERTIFIED SOLUTION
Avatar of DrDamnit
DrDamnit
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
.... Additionally, IE6 cannot support modern SSL/TLS cipher suites, makes your server vulnerable to many attacks (BEAST, POODLE, etc...) Just not a good idea.
... to answer your question, %{example.com} evaluates to nothing. Substitute %{HTTP_HOST}
Avatar of trevor1940
trevor1940

ASKER

@DrDDamnit

You should use this to secure the entire site

I know but It's live and in constant use hence my reason for securing the test sub folder first

I tried

RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}  # Not knowing if  these were varibles

and

RewriteRule (.*)https://%{MyWeb.com}%{/Path/To/Test/area/}  # =   500 Internal server error

RewriteRule (.*) https://%{MyWeb.com}%{/Path/To/Test/area/} # (.*) SPACE https ... doesn't redirect
Thanx