Apache redirect to HTTPS with non standard port numbers

Alles, was den Apache betrifft, kann hier besprochen werden.

Apache redirect to HTTPS with non standard port numbers

Postby plinketyplonk » 31. October 2015 19:52

I am running Windows Server 2012 R12 on a Virtual Host.

I am using IIS which takes up ports 80 for HTTP and 443 for HTTPS.

I also have XAMPP 1.8.1 installed, and can access the content served by Apache via port 8080 for HTTP, and port 444 for HTTPS.

I have been looking at trying to see how I can redirect all Apache traffic to go direct to HTTPS.

I tried the advice here: https://wiki.apache.org/httpd/RewriteHTTPToHTTPS

Using .htaccess - e.g.

Code: Select all
RewriteEngine On
# This will enable the Rewrite capabilities

RewriteCond %{HTTPS} !=on
# This checks to make sure the connection is not already HTTPS

RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
# This rule will redirect users from their original location, to the same location but using HTTPS.
# i.e.  http://www.example.com/foo/ to https://www.example.com/foo/
# The leading slash is made optional so that this will work either in httpd.conf
# or .htaccess context


But I think in my case things are complicated by the fact I have to redirect e.g.

http:8080//example.com/ to https:444://example.com/

I can't work out how I would do that - is it possible? I tried adding in port 444 via this:

Code: Select all
RewriteEngine On
# This will enable the Rewrite capabilities

RewriteCond %{HTTPS} !=on
# This checks to make sure the connection is not already HTTPS

RewriteRule ^/?(.*) https:444//%{SERVER_NAME}/$1 [R,L]
# This rule will redirect users from their original location, to the same location but using HTTPS.
# i.e.  http://www.example.com/foo/ to https://www.example.com/foo/
# The leading slash is made optional so that this will work either in httpd.conf
# or .htaccess context


However, doing that redirected this:

http://example.com:8080/

to this in the address bar:

http://example.com:8080/C:/xampp/htdocs/https:444//example.com

Is it possible to do what I'm trying to do?

Thanks
plinketyplonk
 
Posts: 2
Joined: 31. October 2015 19:49
Operating System: Windows Server 2012 R12

Re: Apache redirect to HTTPS with non standard port numbers

Postby Altrea » 31. October 2015 19:56

ports must be added post TopLevelDomain

wrong:
https:444://example.com/

correct:
https://example.com:444/
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 8286
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: Apache redirect to HTTPS with non standard port numbers

Postby plinketyplonk » 31. October 2015 20:51

Doh! I'm sorry - my mistake.

This is now working:

Code: Select all
RewriteEngine On
# This will enable the Rewrite capabilities

RewriteCond %{HTTPS} !=on
# This checks to make sure the connection is not already HTTPS

RewriteRule ^/?(.*) https://%{SERVER_NAME}:444/$1 [R,L]
# This rule will redirect users from their original location, to the same location but using HTTPS.
# i.e.  http://www.example.com/foo/ to https://www.example.com/foo/
# The leading slash is made optional so that this will work either in httpd.conf
# or .htaccess context


Thanks for your help
plinketyplonk
 
Posts: 2
Joined: 31. October 2015 19:49
Operating System: Windows Server 2012 R12


Return to Apache

Who is online

Users browsing this forum: No registered users and 7 guests