1

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.

2
  • Check out this page: stackoverflow.com/questions/234723/… it has lot of generic solutions for reference. Commented Dec 8, 2012 at 1:05
  • You should also consider canonicalising the www vs non-www. Commented Dec 27, 2016 at 19:10

1 Answer 1

1

Give this a try:

RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} 
Sign up to request clarification or add additional context in comments.

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.