2

I'd like to redirect any insecure request to https, AND make sure that the url always uses 'www'. This is what I have but doesn't seem to work. What am I missing?

 Options +FollowSymLinks RewriteEngine On RewriteCond %{HTTP_HOST} ^domain.com [NC] RewriteCond %{HTTP_HOST} ^www.domain.com [NC] RewriteRule ^(.*)$ https://www.domain.com/$1 [L,R=301] 

2 Answers 2

3

You can use:

Options +FollowSymLinks RewriteEngine On RewriteCond %{HTTP_HOST} !^www\. [OR,NC] RewriteCond %{HTTPS} off RewriteRule ^ https://www.domain.com%{REQUEST_URI} [NE,R=301,L] 
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks. Works perfectly.
0
## Redirecting HTTP to HTTPS RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] ## Redirecting non WWW to WWW RewriteEngine On RewriteCond %{HTTP_HOST} ^domain\.tld$ [NC] RewriteRule ^(.*)$ http://www.domain.tld/$1 [R=301,L] 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.