7

There are many questions about redirecting HTTP to HTTPS like this:

<VirtualHost *:80>
    ServerName www.example.com
    Redirect / https://www.example.com/ 
</VirtualHost>

<VirtualHost *:443>
    ServerName www.example.com
    # ... SSL configuration goes here
</VirtualHost>

but I need to do the other way around, from HTTPS to HTTP, possibly by not using mod_rewrite. Is that possible?

Apache Version: Server version: Apache/2.4.7 (Ubuntu)

I tried this but it doesn't work:

<VirtualHost _default_:443>
        ServerName example.com
        ServerAlias *.example.com
        Redirect "/" "http://example.com/"
</VirtualHost>
somonek
  • 373
  • 1
  • 6
  • 13
  • What apache version are you running? – Dusan Bajic May 11 '16 at 08:26
  • @dusan.bajic Server version: Apache/2.4.7 (Ubuntu) – somonek May 11 '16 at 08:34
  • Possible duplicate of [Recommended way to to redirect HTTP requests to HTTPS](http://stackoverflow.com/questions/37002582/recommended-way-to-to-redirect-http-requests-to-https) – Tom May 11 '16 at 08:38
  • If you check the error_log, I would bet that you see something like `[error] Server should be SSL-aware but has no certificate configured [Hint: SSLCertificateFile] ((null):0)`. This is from not having the SSL assertion. – Tyler Christian Aug 17 '18 at 22:06

1 Answers1

3

Here is code that work for me.

<VirtualHost *:80>
    ServerName example.com  
    ServerAlias www.example.com 
    DocumentRoot /var/www/html/example.com
</VirtualHost>

<VirtualHost *:443> ServerName example.com RewriteEngine on RewriteRule ^ http://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent] </VirtualHost>

Kirit Patel
  • 122
  • 9
  • 2
    Not sure why this answer has been down voted? Instead of the comments under the question, that's the only answer here which at least tries to NOT ignore that the question is regarding redirectoing https to http and not upsidedown! What's going on in the web? Tries "somebody" to force us all to use certificates and https?? Not every website needs that! But yeah, right, something to pay for. Again! – nilsun Apr 26 '20 at 22:06