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: Redirecting both lan and web to https
Author
SimonB27



Joined: 30 May 2017
Posts: 1
Location: UK, St Albans

PostPosted: Tue 30 May '17 23:40    Post subject: Redirecting both lan and web to https Reply with quote

No question too simple it says - I hope so. I'm new to Apache. I hope I have an easy-to-solve problem but I can't find a definitive answer on the "proper" way to do it.

My first project that needs me to understand a bit about using Apache2 is an owncloud server. I'd like to force https but I don't understand how to deal with the redirect of http requests on port 80 to port 443. I need to be able to use laptops that will sometimes be connecting through the internet via something.dyndns.org/owncloud and sometimes will be inside my lan where my router will loopback.

I know I could just not forward port 80 requests originating from the internet to my owncloud server but I have ambitions for other projects so I'd like the redirect to work only for the something.dyndns.org/owncloud and not for something.dyndns.org or something.dyndns.org/anything_else and leave port 80 available for other projects.

I get the feeling there is a "proper" way to do this but the whole question of servernames, server aliases and redirects is, I'm afraid, confusing the hell out of me... or do I need to go the RewriteEngine route?

I'd be very grateful for advice from someone for whom presumably this stuff is obvious.
Back to top
James Blond
Moderator


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

PostPosted: Fri 09 Jun '17 10:38    Post subject: Reply with quote

Working any requested hostname

Code:

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


Reply to topic   Topic: Redirecting both lan and web to https View previous topic :: View next topic
Post new topic   Forum Index -> Apache