user1886952
user1886952

Reputation: 11

.htaccess redirect from www and non www to https

I need a simple way to force an https redirect for incoming non-https requests.

In other words, if a request comes in for http://www.example.com or http://example.com I want it to be redirected to https://www.example.com or https://example.com, respectively.

Either of the two options is valid in my scenario - as long as both www and non-www requests get redirected.

I've tried a number of solutions based on a variety of resources, but most of them wind up with me getting an infinite loop - or some kind of error message that redirection has not been properly set-up.

I am using media temple as my host and would love to be able to do this via editing my .htaccess file.

Upvotes: 1

Views: 253

Answers (1)

Madbreaks
Madbreaks

Reputation: 19539

Give this a try:

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

Upvotes: 1

Related Questions