How to disable Letsencrypt redirect all requests to secure HTTPS access

August 16, 2016 24.3k views
Ubuntu Apache Configuration Management

I did the Letsencrypt installation and it works great.
I choose the option to redirect all requests to secure HTTPS access.

I saw those lines added by Letsencrypt in /etc/apache2/sites-available/000-default.conf

        RewriteEngine on
        RewriteCond %{SERVER_NAME}
        RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]

Now I want to disable this feature and to have a part of website without ssl.
So I commented those lines and reloaded Apache but the redirection is still active: still redirect to

How can I fix that?

2 Answers

Yes you are right it was a cache problem because of header time config.

Found the solution here :

Seems like you added the HSTS header to your apache conf. This directive tells the browser visiting your site that for the max age configured in the directive, the browser should access your site always using https. So the “problem” is in your browser right now.

In your apache conf you should have/had something like this:

Header always set Strict-Transport-Security "max-age=63072000; includeSubdomains; preload"

3.- Recover all the apache and letsencrypt files that you removed, edit apache conf and change the header directive using max-age=0, something like this:
Header always set Strict-Transport-Security “max-age=0; includeSubdomains; preload”

Reload or restart apache and visit again your site, once visited the browser will ignore the htst header and you could access your site using only http.

I modified this directive using max-age=0 and it worked right away....

Please post your /etc/apache2/sites-available/000-default.conf file and .htaccess file if you have one.

One more thing to note is browsers will cache redirects. You may want to test it using incognito mode.

Have another answer? Share your knowledge.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!