These are snippets for your .htaccess file, comments are after the # hash tags and explain what each snippet does.
Replace “yoursite.com” with your actual website, of course!
# www on all URLs. RewriteCond %{HTTP_HOST} ^yoursite.com [NC] RewriteRule ^(.*)$ http://www.yoursite.com/\ [L,R=301] # Switch to HTTPS version of the site. RewriteCond %{HTTPS} !on RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # Ensure all web addresses have a trailing slash. RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !(.*)/$ RewriteRule ^(.*)$ http://www.yoursite.com/\/ [L,R=301]
The “L” in the square brackets tells the server if your rule is fulfilled with a match that is the “Last” directive to follow. The “R” stands for “Redirect” and allows you the option of defining what kind of redirect, typically, this is a 301 Permanent Move.