I'm trying to redirect a website to HTTPS, but there is one URL that needs to be accessed via HTTP. Currently I just have this in .htaccess:

Redirect 301 / https://www.example.com

I need to have the following URL available through HTTP:


It is an assistant page separate from the website, that in labor is accessed via QR code.

How can I force HTTPS for everything except that one page listed above?

  • 2
    Redirecting to HTTPS shouldn't keep a QR code from working. Users that scan the code would just get redirected to the page using HTTPS. What is the problem with that? Commented Mar 23, 2021 at 19:21
  • Is the directive you posted intended to redirect HTTP to HTTPS? Do HTTP requests have a different document root to HTTPS requests?
    – MrWhite
    Commented Mar 23, 2021 at 19:29

1 Answer 1


I agree with Stephen's comment: HTTPS will not break the QR code itself.
There might be some hosting reasons to keep your QR-encoded URL untouched. I guess you may want to avoid any HTTPS issue (old browsers, etc.) with this URL (and its children).

Here are Apache directives which, in an .htaccess file, will redirect all requests to HTTPS, except http://(www.)example.com/asistente and its children URLs.

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !^/asistente($|/)
RewriteRule (.*) https://www.example.com/$1 [R=301,L]
  • 1
    "as suggested by MrWhite" - I wasn't referring to the QR code... I was just querying the OP's use of Redirect in their "current" .htaccess file - since ordinarily, that would have resulted in a (malformed) redirect loop, yet we are led to assume that it is working as intended - which is puzzling.
    – MrWhite
    Commented Mar 26, 2021 at 16:21
  • Oh yes, sorry @MrWhite
    – Éric
    Commented Mar 26, 2021 at 16:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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