Switching site from http to https, but in .htaccess I can't upload file successfully after adding

RewriteEngine On

RewriteCond %{HTTPS} !=on

RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

in the file using notepad to enforce secure page. Format is UTF-8.

Any ideas?

  • 1
    What do you mean you can't upload it? Please explain what is happening. Feb 5, 2020 at 18:55

1 Answer 1


using notepad to enforce secure page. Format is UTF-8.

The problem is that Windows Notepad saves UTF-8 files with a Byte Order Mark (BOM) - which it uses to identify the file encoding (other systems, Apache included, do not require this). If you look at the saved file in a hex editor, you will see the 3 bytes EF BB BF (that displays as  in CP1252) at the start of the file.

It is likely that this BOM is breaking Apache. (I would perhaps expect you are seeing a 500 Internal Server Error response?)

If using Notepad, save as "ANSI" (for simple files like this), or use a different editor.


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.