I’ve made a ton of websites over the years, and somethings are done every time.  Redirects in the .htaccess file is one of those things that’s always on the checklist.

Don’t worry about Googling how to do each redirect each time.  Just bookmark this page.

This .htaccess code snippet handles redirecting any requests to…

  • Force the www subdomain if accessed without it
  • Force SSL (https://) if accessed with http://

Put the following in the .htaccess file preferably towards the top, before the WordPress section…

Of course, replace domain.com  with your own domain.

Note: I prefer to use 302 redirects instead of 301 redirects because…

  1. 302s don’t get cached in your browser like 301s.  So, if you mess something up, you can change it and test it without having restart your browser.
  2. I’ve also read that 301s don’t have any more capability of transferring page rank, and 302s actually maintain the transferring page rank more over time.

Leave a Reply

avatar
  Subscribe  
Notify of