How to Redirect Using htaccess (301)

Need to redirect one site to another? Perhaps you’re moving your WordPress website to a new location.

Looking to use .htaccess to improve your site’s SEO? Maybe you need to redirect one URL to another within your WordPress website.

Take a look at this quick and easy guide to the basics of 301 redirects using .htaccess.

.htaccess 301 Redirect (Domain 1 -> Domain 2)

[adsense_id=”1″] When moving a site from one domain to another, you typically want the same directory and file structure reflected in your redirect, and the code below will do this for you. This will allow to forward to under all circumstances; for example, a call for will redirect to

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*)$1 [R=301,L]

Simply place the .htaccess file at the public root of, replacing in the code with your new domain. Not only will this redirect traffic, but it will also alert search engines like Google that your web address has permanently changed, encouraging them to deindex the old site and freshly index the new.

.htaccess 301 Redirect ( <->

To keep all of the link love your site receives in one place, many webmasters like to redirect to, or vice versa. The code below will do this for you.

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^ [nc]
rewriterule ^(.*)$$1 [r=301,nc]

Place this .htaccess file at the public root of your site, replacing (two instances) in the code with your actual domain name. This will push all of the so-called link juice to a single domain, whether your fans and readers link to your URL with a “www” or not.

Share Your Thoughts