Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 302
  • Last Modified:

https redirect

I want to redirect all pages in my site to https.  SSL is installed and I can type in the https for all files but want to automatically have https come up when a user enters the site.

Site is on apache server.

All my web searches do not give clear solutions.  I just need a simple htaccess file (I think)
0
dkern18195
Asked:
dkern18195
  • 4
  • 3
  • 2
1 Solution
 
Maximus5684Commented:
Add the following line to your httpd.conf file:

Redirect permanent / https://<address>/

Open in new window


Where <address> is the web address that you want redirected. Make sure to restart Aapache afterward.
0
 
dkern18195Author Commented:
I am not a server admin so I cannot restart the server.
0
 
grahamnonweilerCommented:
To handle this using a .htaccess file will require that the mod_rewrite module is loaded within Apache (if you are on shared hosting this is normally the default) then create a .htaccess file containing the following:


Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI}  [R=301,L]

Open in new window


Once the .htaccess file is written it's working,  there is no need to restart Apache
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
dkern18195Author Commented:
This gave an error.  Is there something I should have changed in the copy you provided?

The site is on a dedicated ip address.  Does that make a difference?
0
 
dkern18195Author Commented:
Server admins tell me that mod-rewrite is enabled on the servers
0
 
Maximus5684Commented:
Try this instead:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

Open in new window


If that doesn't work, give us the error code.
0
 
grahamnonweilerCommented:
Try a different approach:

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://<yourdomainname>/$1 [R,L]

Open in new window


You should replace <yourdomainname> with your actual domain name.
0
 
Maximus5684Commented:
One last way that I've found which does not use mod_rewrite and gets around some "double login" problems that can occur if you use authentication:

SSLOptions +StrictRequire
SSLRequireSSL
SSLRequire %{HTTP_HOST} eq "yoursite.com"
ErrorDocument 403 https://yoursite.com

Open in new window


Replace yoursite.com with your domain. This also does not tie it to a specific port if your site is being hosted on multiple ports.
0
 
dkern18195Author Commented:
Thank you both for helping with this.  I still need to test the last solution but this one worked
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI

The other took me to google search and brought up the domain at the top of the search.
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

  • 4
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now