301 Redirect Examples .htaccess

To Move a single page

Quick, easy and seamless for your visitors.

Redirect 301 /oldpage.html http://www.example.com/newpage.html

To Move an entire site

This will catch any traffic on your old site and redirect it to your index page on your new server. If you want to redirect each page to its new spot, this isn’t the one for you.

Redirect 301 / http://www.example.com/

Changed file extension?

This example is perfect if you’ve decided to switch to .php from .html pages. It will look for any .html page and redirect it to .php (ie http://www.example.com/yourpage.html and redirect it to http://www.example.com/yourpage.php). Now, be careful with this, it does mean any html page. I did this on one of my sites and had totally forgotten I had an iframe with .html content on some pages… I didn’t notice for weeks that it was broken :S.
So learn from my mistake 😉 check, double check, then check again.

RedirectMatch 301 (.*)\.html$ http://www.example.com$1.php

Leave a comment