Mahngiel Posted May 8, 2012 Share Posted May 8, 2012 In order to redirect an HTTP to HTTPS, do I need a vhost for both ports? I have a site setup to listen on port 443 but not 80. Would this cause rewrites / redirects to not work? Furthermore, can you remove the https: from the URI while maintaining SSL ("pretty URIs") ? HTTPS link works, but HTTP (and lack of protocol) do not. ports.conf Listen 46.x.x.x:80 <IfModule mod_ssl.c> Listen 46.x.x.x:443 </IfModule> httpd.conf NameVirtualHost www.domain.com:80 NameVirtualHost www.domain.com:443 VHost file <VirtualHost sub.domain.com:443> ServerAdmin xxx@gmail.com ServerName sub.domain.com DocumentRoot /var/www/path //-- Redacted SSL file info -- // RewriteEngine on RewriteCond %{HTTPS} !=on RewriteCond %{HTTP_HOST} !^$ RewriteCond %{SERVER_PORT} !^443$ RewriteCond %{HTTP_HOST} ^sub.domain.com$ RewriteRule ^/?(.*) https://%{SERVER_NAME}%{REQUEST_URI}/$1 [R,L] <Directory "/var/www/path"> AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost> Quote Link to comment https://forums.phpfreaks.com/topic/262269-two-vhosts-needed/ Share on other sites More sharing options...
gizmola Posted May 9, 2012 Share Posted May 9, 2012 Yes, SSL is an entirely different protocol than HTTP, and you absolutely must configure your HTTPS site as a seperate vhost. The webroot can be the same between the sites, but they are completely different hosts and share nothing between them in terms of cookies, state etc. You can not have one vhost that supports both protocols. Quote Link to comment https://forums.phpfreaks.com/topic/262269-two-vhosts-needed/#findComment-1344150 Share on other sites More sharing options...
Mahngiel Posted May 9, 2012 Author Share Posted May 9, 2012 Very good, thanks gizmola. Quote Link to comment https://forums.phpfreaks.com/topic/262269-two-vhosts-needed/#findComment-1344215 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.