redirect http tp https using mod_rewrite on apache 2.2

114 Views Asked by At

I have a working mywebsite.com hosting port at 8080. I was able to redirect the port from 8080 to open port 80 using mod_rewrite. Now i have a new requirement to redirect that particular http to https (ssl) port. I have tried so many possibilities in doing that and still failed throwing forbidden access error 403.

FYI I have not been using .htaccess for this access because mywebsite.com is owned by 3rd party and they refused to give me the path directory of the apps.

Apache: 2.2

OS : windows server 2016

<VirtualHost *:80>

RewriteEngine On

RewriteRule ^/(.*) http://mywebsite.com:8080/VirtualHostBase/http/%{SERVER_NAME}:80/mywebsitedoc/VirtualHostRoot/$1 [L,P]

</VirtualHost>

Listen 443

<VirtualHost *:443>

ServerName mywebsite.com

SSLEngine on

SSLCertificateFile "C:/Apache2.2/conf/mywebsite.com.crt"

SSLCertificateKeyFile "C:/Apache2.2/conf/mywebsite.com.key"

SSLCertificateChainFile "C:/Apache2.2/conf/mywebsite.com.gd_bundle-g2-g1.crt"

</VirtualHost>

1

There are 1 best solutions below

0
Azrim Ariffin On

I have got the answer as below. FYI it was zope web server running at port 8080 and i required to forward all 80 requests to port 8080

<VirtualHost *:80>

ServerName mywebsite.com

Redirect permanent / https://mywebsite.com:443/

</VirtualHost>

Listen 443

<VirtualHost *:443>

ServerName mywebsite.com

SSLEngine on

SSLProxyEngine on

RewriteEngine On

RewriteRule ^/(.*) http://mywebsite.com:8080/VirtualHostBase/https/%{SERVER_NAME}:443/staffportal/VirtualHostRoot/$1 [L,P]

SSLCertificateFile "..."

SSLCertificateKeyFile "....."

SSLCertificateChainFile "....."

</VirtualHost>

Regards, AA