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>
In Apache, the preferred way to redirect HTTP to HTTPS is to configure the 301 redirect in the domain's virtual host.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With