Creating a redirect on your WordPress site can seem a little intimidating if you aren’t familiar with Apache and Regular Expressions. It’s also important to add your redirects without breaking default WordPress functionality.

WordPress htaccess Redirect Rewrite Posts and Categories

Perhaps the most important aspect of redirecting your pages is maintaining your current Search Engine position, and to accomplish that you’re going to need to do do a 301 Redirect; 301 being the HTTP Status Code for “Moved Permanently”.

The .htaccess file can be found in your root directory (often /www or /public_html). You can open that file in any text editor to view the contents.

Default WordPress .htaccess File
If you mess things up, you can always revert back to the default WordPress .htaccess file by copying and pasting the code below – provided you hadn’t already modified it before this tutorial.

# Default WordPress 3.0+ htacess file
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress

Redirect 301

By far the easiest way to add a simple URL-to-URL redirect is by using redirect 301. The format of this simple Apache command is redirect 301 old new.

Redirecting WordPress Pages

redirect 301 /home.php /index.php
# Or
redirect 301 /home.php

Redirecting WordPress Categories

redirect 301 /articles

By redirecting entire categories or directories, you’re also re-directing requests to specific pages from on directory to another. For example, with the category redirect above, a user attempting to visit /articles/post.php would be redirected to tutorials/post.php.


Mod_Rewrite is a bit more complicated, as it employs Regular Expressions to match and forward URLs.

Adding WWW to WordPress URL

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^(.*)$$1 [R=301,L]

No matter how you use Mod_Rewrite, you must first turn the RewriteEngine On, as seen in the sample above.

Redirect File Types
Let’s say you’re in a situation where you upload reports in the form of Word documents, but want to start using PDFs instead. Once you’ve uploaded all of your PDF files you can use the following code to foward all .doc files to the same location with a .pdf extension.

RewriteEngine on
RewriteBase /
RewriteRule (.*).doc$ /$1.pdf


There are several ways to go about redirecting one page to another – Meta tags and PHP Headers to name a couple, but .htaccess continues to be among the best because you can maintain your Search Engine rankings.

POSTED IN Tutorials

5 Responses to : Using .htaccess to Create WordPress 301 Redirects

  1. James Lapardo says:

    nice, ive really been trying to find a tutorial on putting redirects in wordpresses htaccess file, thx! +1

  2. WP Newb says:

    Good post, keep it up!

  3. Ben Gibson says:

    nice easy to follow wordpress redirection tutorial!

  4. Krakow says:

    WONDERFUL Post! Thanks for share, WordPress’ htaccess file has always confused me a bit.

  5. vondemeaw says:

    This is exactly what I was looking for, thanks!