DbAppWeb.com

Menu
  • Home
  • Linux
  • HP-UX
  • macOS
  • Windows
  • Web Servers
  • App Servers
  • Storage

Force HTTPS connections in an Apache server environment

May 8, 2018 DbAppWeb Admin

To secure the entire site we need to redirect all the requests to HTTPS which are coming through HTTP or any other.

Redirect all connections over HTTPS

To redirect all the requests over SSL we need to add the below RewriteCond in Apache configuration file /etc/httpd/conf/httpd.conf

[root@dbappweb ~]# vi /etc/httpd/conf/httpd.conf

 

.
.
RewriteEngine on
ReWriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*)$ https://%{HTTP_HOST}/$1 [NC,R=301,L]
.
.

or

.
.
RewriteEngine on
ReWriteCond %{SERVER_PORT} 80
RewriteRule ^/(.*)$ https://%{HTTP_HOST}/$1 [NC,R=301,L]
.
.

 

RewriteEngine on: This will enable the Rewrite capabilities
ReWriteCond %{SERVER_PORT} !^443$: This check makes sure that the connection is not already HTTPS, a connection made on ports other than 443 will not be an HTTPS connection.
RewriteRule ^/(.*)$ https://%{HTTP_HOST}/$1 [NC,R=301,L]: This rule will redirect users from their original location to the same location but using HTTPS.
Example: Visitors trying to access http://www.dbappweb.com/category/apache/ will be redirected to https://www.dbappweb.com/category/apache/
ReWriteCond %{SERVER_PORT} 80: This check make sure that connection is not already HTTPS, port 80 indicates a non-secure HTTP connection.

Prev Article
Next Article
Tags:Apache Apache 2.2.3 Web Server

Leave a Reply Cancel Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  • Popular
  • Recent

Categories

  • Android (2)
  • Blogger (16)
  • Domain and Hosting (1)
  • Hardware Issues (7)
  • HP-UX (55)
  • HPE Data Protector (9)
  • IBM Lotus Notes (2)
  • IBM WebSphere Application Server (16)
  • Internet Tips & Tricks (15)
  • iOS (8)
  • JBoss/WildFly Application Server (2)
  • Linux (76)
  • macOS (15)
  • Microsoft Windows (31)
  • News and Updates (11)
  • Oracle Database (5)
  • SSL/TLS (1)
  • Storage Servers (23)
  • Tools/Softwares (1)
  • VMware ESXi (17)
  • Web Servers (14)
  • WordPress (5)

Archives

DbAppWeb.com

Solution of Database, Application and Web Server Problems

About DbAppWeb.com

One Stop Solution for Database Server, Application Server and Web Server Problems.

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

DbAppWeb on Social Media

Copyright © 2025 DbAppWeb.com
Terms and Conditions   Theme by MyThemeShop.com