Reputation: 9549
I want to force both HTTPS and WWW for my domain.
EX: mydomain.com
should be always https://www.mydomain.com
Is there a way to combine both rewrite rules in ONE simple rule without affecting website stability and SEO?
Upvotes: 0
Views: 113
Reputation: 4254
You can do this via Apache too
<VirtualHost *:80>
ServerName www.example.com
Redirect / https://www.example.com/
</VirtualHost>
<virtualHost *:443>
DocumentRoot /var/www/html/example.com
ServerName www.example.com
</VirtualHost>
Upvotes: 1
Reputation: 10132
Try this
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} !=on [OR]
RewriteCond %{HTTP_HOST} ^mydomain\.com$ [NC]
RewriteRule ^ https://www.mydomain.com%{REQUEST_URI} [R,L]
Upvotes: 2