3

I have multiple sites hosted on an Apache web server.

Site A is HTTPS and Site B is HTTP.

When people go to Site B using HTTPS (I don't know why they do, because there's no HTTPS on it and never was, but they do), they are directed to the Site A. How can I fix that and keep them on Site B?

5

Unfortunately there is no way to catch this before the users get to your web server (in DNS or something). Create a virtual host to handle https requests for SITEB and redirect them to http.

You can also do the same thing with a rewritecond/rewriterule in the SITEA https virtual host.

Essentially the inverse of the following: http://wiki.apache.org/httpd/RedirectSSL

  • 6
    If an HTTPS server to redirect all requests to HTTP can be set up, it's better to serve the whole site over HTTPS. – v7d8dpo4 Sep 12 '16 at 14:33
  • In order for a https request to be handled (and be it for a redirect), it is necessary that a secure connection with mathcing and valid certificate and all that jazz has already been established. – Hagen von Eitzen Sep 12 '16 at 16:47
0

This is happening, because both your domains are served from the same httpd process. In your server/vhost config, the config section specific to listening on port 443 is available only for SITEA.

The users are probably visiting the https for SITEB because of httpseverywhere (or equivalent) browser plugins, which redirects them to https version of websites. Now, when they visit https://site-b.com, the apache server (because SITEB points to your machine's IP) looks for config regarding the port 443; and starts serving the SITEA pages.

I'd suggest that you start serving your customers both your websites over HTTPS (letsencrypt FTW), instead of redirecting from https to http. Alternatively, you can add the following rule set in your Apache's SITEA Vhost config:

RewriteEngine On
RewriteCond %{HTTP_HOST} SITEB [NC]
RewriteRule ^ http://SITEB%{REQUEST_URI} [R=301,L]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.