Redirect HTTPS to HTTP permanently, from Apache VirtualHost
10,292
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>
Author by
somonek
Updated on June 29, 2022Comments
-
somonek almost 2 years
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>
-
Dusan Bajic almost 8 yearsWhat apache version are you running?
-
somonek almost 8 years@dusan.bajic Server version: Apache/2.4.7 (Ubuntu)
-
Tom almost 8 yearsPossible duplicate of Recommended way to to redirect HTTP requests to HTTPS
-
Tyler Christian over 5 yearsIf 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.
-
-
nilsun about 4 yearsNot 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!