Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Forcing Apache to use HTTPS

Posted on 2011-09-02
3
885 Views
Last Modified: 2012-05-12
I have tried several attempts at forcing my RHEL 5 web server running PHP 5.3 and Apache 2.2.3 to always use HTTPS instead of HTTP.   I want wherever anyone goes or whatever anyone types into the address bar of the web browser to automatically use https://

I have tried the following without success:

RewriteCond %{HTTPS} off

RewriteCond %{HTTPS} !=on

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

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

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

RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Need help!
0
Comment
Question by:the-miz
3 Comments
 
LVL 7

Accepted Solution

by:
boon86 earned 500 total points
ID: 36475105
try this:

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

Open in new window

0
 
LVL 77

Expert Comment

by:arnold
ID: 36475125
0
 

Author Comment

by:the-miz
ID: 36475144
Beautiful.  Worked!  Thanks a million
0

Featured Post

Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question