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)
LVL 1
dkern18195Asked:
Who is Participating?
 
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
 
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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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
 
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
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.