How To 301 Redirect a WordPress Article Without a Plugin

This page is in the Code Graveyard where I lay to rest snippets of code that I don't use anymore. Some have lost their usefulness due to the evolving nature of the web, while others have been replaced with better code. "Be Ye Warned!"
To do 301 Redirects with GoDaddy Hosting, go here.

If you ever change the url, slug, or Permalink of an article in WordPress, make sure to do a 301 redirect in the .htaccess file on your server. If you fail to do a 301 redirect, 2 things can happen:

1. The article loses any page ranking that it may have earned. The new url is understood by search engines as a brand new article. The article will have to climb the search engine results list from the bottom. You basically push your article to the “back of the line.”
2. The worst case scenario is that Google search labels you as a spammer. Since the new url is understood as a brand new article, the article will be understood as a duplicate of “the article with the old url.” Google frowns on duplicate content. Your site may get flagged as a spam site that publishes duplicate content. In that case, forget about climbing the search results list.

It’s never too late to build your website’s reputation back up. Start using 301 redirects every time you change the url, slug, or Permalink of an article. Here’s how to do it.

Step 1 – Go To Your Server

Log in to your server.

Step 2 – Find The .htaccess File

Locate the .htaccess file in the root directory of the website. There may be other .htaccess files in other folders, so make sure to find the correct one. Repeat: You’re looking for the one in the root directory. This is the main location of your website; it’s probably the default directory when you first log in to your server files. If you’re hosting several sites on one hosting account, there will be several .htaccess files. Find the correct one. Open the .htaccess file. On most servers, you have to select the file and then click “Edit” in order to open the file.

Step 3 – Make Some Room

Don’t mess with any of the existing code in this file. You are going to add a blank line where I tell you, but be very careful to not erase anything. Make the blank line anywhere AFTER these lines:

<IfModule mod_rewrite.c>
RewriteEngine On

but BEFORE these lines:


# END WordPress

Step 4 – Do The 301 Redirect

On new blank line, enter this Rewrite Rule:

RewriteRule ^old-slug$ [L,R=301]

You must make 2 changes to the Rewrite Rule above. Pay attention, the tiniest details matter here. Look at the line of code closely.

Change 1, for Step 4

You will change the letters “old-slug” to your own article slug (the old slug of the article that you are trying to change.) The slug is not the entire url. The slug is only the part of the url that comes after the url of your WordPress blog. For example, if your WordPress blog homepage is at, and the article we’re dealing with is at, then the slug is bad-article-slug. Another example: if you’re blog is at, and the article we’re dealing with is at, then the slug is still bad-article-slug.

Do not include quotation marks around your “old-slug”, I’m just using quotes here for clarity. Do not include a slash (/) before or after your slug. Do not touch or change the the ^ symbol before your old-slug, or the $ after your old-slug. There are no spaces between ^old-slug$. But there is one space before the ^, and one space after the $.

Change 2, for Step 4

You will change the url “” to the new url of your article. Here you use the entire url of the article, as you can see. Do not add a slash to the very end. There is one space after this url. Do not touch the [L,R=301].

That’s it. Be sure to save these changes in your .htaccess file. You can test your changes by typing the old url in your browser. It should take you to the new url automatically. The best part of this is that Google search engine will smile on you. Now you are preserving your ranking for this article. If you decide to change the slug again, don’t alter the Rewrite Rule we just entered. Rather, create a new Rewrite Rule and add it just like we did with this one.

See more: , , ,

We've 3 Responses

Questions and Comments are Welcome

Your email address will not be published. All comments will be moderated.

Please wrap code in "code" bracket tags like this: