To make it work in both environments you can combine both conditions:
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
More Related Contents:
- How to prevent a file from direct URL Access?
- Redirect to other domain but keep typed domain
- how to remove folder name from url using htaccess
- Remove ‘index.php’ from URL with .htaccess
- Remove .php from urls with htaccess
- htaccess 301 redirect – Remove query string (QSA)
- 301 Redirect to replace all spaces to hyphens
- .htaccess RewriteRule to path without changing URL
- htaccess force https and redirect www to non-www, but no other subdomains
- Redirect all traffic to root of another domain
- Apache mod_rewrite REDIRECT_STATUS condition causing directory listing
- Set RewriteBase to the current folder path dynamically
- deny direct access to a folder and file by htaccess
- How can I match query string variables with mod_rewrite?
- How can I use .htaccess to hide .php URL extensions?
- apache mod_rewrite one rule for any number of possibilities
- Match Question Mark in mod_rewrite rule regex
- Convert to lowercase in a mod_rewrite rule
- How to create clean url using .htaccess
- Tips for debugging .htaccess rewrite rules
- htaccess redirect to https://www
- Hidden features of mod_rewrite
- Pretty URLs with .htaccess
- How to force https on elastic beanstalk?
- Forbidden You don’t have permission to access / on this server [closed]
- mod_rewrite: remove trailing slash (only one!)
- CSS, JS and images do not display with pretty url
- Rewrite Problem – L(ast) not being respected?
- htaccess RewriteRule page with query string
- URL rewriting for different protocols in .htaccess