I am running Apache 2.4.18 on Windows Server 2008 R2 and PHP 5.6.18 on a physical Machine called SERVER1 and it is joined to my internal domain called example.com
.
My Apache server by default have SSL turned on. I need to run 2 different sites where one site uses SSL and the other one does not.
Here is what I have added to my httpd-vhosts.conf file in attempt to get it to work
How can I get this to work?
<VirtualHost *:80>
ServerName SERVER1.example.com
Redirect permanent "C:/phpsites/app1" https://sub1.example.com/
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/phpsites/app2/public"
ServerName SERVER1.example.com
ServerAlias sub2.example.com
SSLEngine Off
<Directory "C:/phpsites/app2/public">
AllowOverride All
Require all Granted
</Directory>
</VirtualHost>
<VirtualHost *:443>
DocumentRoot "C:/phpsites/app1"
ServerName SERVER1.example.com
ServerAlias sub1.example.com
SSLEngine On
SSLCertificateFile "c:/Apache24/conf/certificate/cert.crt"
SSLCertificateKeyFile "c:/Apache24/conf/certificate/private.key"
<Directory "C:/phpsites/app1">
AllowOverride All
Require all Granted
</Directory>
</VirtualHost>
The setting above does not work properly. When I go to https ://sub1.example.com Apache redirects me to the correct site C:/phpsites/app1. When I go to http ://sub1.example.com it redirects me to C:/phpsites/app2/public but I don't want that to happen. And when I go to http://sub2.example.com I get redirected to https ://sub1.example.com for some reason.
I need to direct any user that is looking for http://sub1.example.com or https://sub1.example.com to https ://sub1.example.com.
And any users that is looking for http://sub2.example.com or https://sub2.example.com to go to http ://sub2.example.com
Here is what I get when I execute httpd -D DUMP_VHOSTS
> VirtualHost configuration:
>
> *:80 is a NameVirtualHost
>
>
> default server SERVER1.example.com
> (C:/Apache24/conf/extra/httpd-vhosts.conf:27) port 80 namevhost
> SERVER1.example.com (C:/Apache24/conf/extra/httpd-vhosts.conf:27)
>
> port 80 namevhost SERVER1.example.com
> (C:/Apache24/conf/extra/httpd-vhosts.conf:34) alias sub2.example.com
>
>
> *:443 is a NameVirtualHost default server SERVER1.example.com (C:/Apache24/conf/extra/httpd-vhosts.conf:52) port 443 namevhost
> SERVER1.example.com (C:/Apache24/conf/extra/httpd-vhosts.conf:52)
> alias sub1.example.com
>
> port 443 namevhost SERVER1.example.com
> (C:/Apache24/conf/extra/httpd-ssl.conf:85)
My setting are actually working fine. For some reason Firefox is caching the dns in the browser.
I had to delete my temp file and everything worked like a charm!
It is bothering me and would like to know why would Firefox cache the dns!
I hope this note helps someone in the same boat!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.