logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Redirect everything to https://www.url
Author
star_wars_fan



Joined: 11 Mar 2017
Posts: 1
Location: Naboo

PostPosted: Sun 12 Mar '17 14:06    Post subject: Redirect everything to https://www.url Reply with quote

Hi,

I'm using Debian 8 with Apache 2.4 and I need to redirect everything to https://www.domain.com

Example:
http://domain.com redirects to https://www.domain.com
http://www.domain.com redirects to https://www.domain.com
https://domain.com redirects to https://www.domain.com

After searching google, I've decided to use the following configuration.
But, I need to be sure that's the correct way to do it.
Can you please tell me your opinion?

000-default.conf
Redirect permanent / https://www.domain.com/

default-ssl.conf
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !=www.domain.com [NC]
RewriteRule ^(.*) https://www.domain.com/$1 [NS,L,R=permanent]
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7288
Location: Germany, Next to Hamburg

PostPosted: Tue 14 Mar '17 11:42    Post subject: Reply with quote

I would use

Code:
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Back to top


Reply to topic   Topic: Redirect everything to https://www.url View previous topic :: View next topic
Post new topic   Forum Index -> Apache