Jump to content

Recommended Posts

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>

Link to comment
https://forums.phpfreaks.com/topic/262269-two-vhosts-needed/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/262269-two-vhosts-needed/#findComment-1344150
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.