0

I have a SSL on my site and would like to redirect all my http pages to https I find something below and work for www.yourdomain.com.

If I also need transfer all yourdomain.com(without www) to https what should I add to htaccess? Thanks!

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]
<!-- Please put the redirect without www here, thanks-->
Simone Carletti
  • 173,507
  • 49
  • 363
  • 364
goomember
  • 11
  • 1
  • 1
    possible duplicate of [How to redirect all HTTP requests to HTTPS](http://stackoverflow.com/questions/4083221/how-to-redirect-all-http-requests-to-https) – bud-e Jan 13 '15 at 08:40

1 Answers1

0

A simple Google search reveals hundreds of results. For example, this official FAQ.

RewriteEngine On
# This will enable the Rewrite capabilities

RewriteCond %{HTTPS} !=on
# This checks to make sure the connection is not already HTTPS

RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
# This rule will redirect users from their original location, to the same location but using HTTPS.
# i.e.  http://www.example.com/foo/ to https://www.example.com/foo/
# The leading slash is made optional so that this will work either in httpd.conf
# or .htaccess context
Simone Carletti
  • 173,507
  • 49
  • 363
  • 364