Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've read a lot about redirecting and also checked out previous questions here, but NONE could answer my question. I think the problem is that I just don't understand the difference between the different redirection methods and thus don't know which one to choose in my situation and how to implement it.

I'm really sorry, but I just don't understand all the terms although I tried! :(

I was of the impression that 301 redirects are the best solution, especially also good for SEO. There is a plugin that will do that for me, called "Redirection".

What I want to do is to change the URL of just a few of my blog posts for SEO reasons (e.g. the URL didn't contain the keyword). I don't want to change the permalink structure or change the whole domain!

Would 301 redirection be the correct way in my case? Should I use a plugin in that case or can I easily to that by modifying my htaccess file?

share|improve this question
2  
You can change the permalink (but NOT the prefixes/structure) for any individual post or page right from the edit screen. First, edit a post... directly under the post title you will see the "Permalink:" preview text. Right next to that is an "Edit" button. Click on edit, and change that specific post's permalink to whatever you want. –  Matt Van Andel Mar 3 '13 at 15:36
    
@Matt Van Andel: I know that. The problem is that all the posts I have already written contain links to those other posts where I want to change the URL. That would result in a lot of 404 errors. That's why I wanted to create a redirection. The only other option is that I go through all 100+ posts and change the internal links to those posts manual! :( –  japanworm Mar 3 '13 at 15:38
1  
Gotcha! One the great weaknesses of WordPress... that it can't automatically update links. This is an easy .htaccess fix though. Answer coming... –  Matt Van Andel Mar 3 '13 at 15:40

2 Answers 2

up vote 1 down vote accepted

First, make sure that Rewrites are enabled for your server, then add this to your .htaccess file in WordPress's root directory...

RewriteRule your-old-page-permalink/ http://www.yoursite.com/your/new/permalink/ [R=301,L]

This is a greedy match, so your-old-page-permalink/ just needs to correspond to the old post's SLUG (that's the editable part of the permalink on your post edit screen).

So, go to your admin, grab the old permalink slug, add a rewrite rule to your .htaccess, and then change the permalink in WordPress to whatever you want (making sure the RewriteRule matches the new url as well). Do this for each post whose permalink you want to change.

One more thing...

Be sure to put this rule at the top of your .htaccess file... or at least BEFORE WordPress's auto-generated rewrite rules. The L means "Last" and will stop execution... and since WordPress has L rules itself, if this is put after, it will never trigger.

Also, if the redirects don't seem to be working as-is, add this above them (which will activate rewrites if they aren't already)...

<IfModule mod_rewrite.c>
RewriteEngine On
</IfModule>
share|improve this answer
    
Thank you! How can I check if my server has rewrites enabled? And in an actual example how would the Rewrite Rule look for the following URL example.com/banana-is-great change to example.com/bananas-are-great –  japanworm Mar 3 '13 at 15:46
    
If WordPress's rewrites are working, then you have Rewrites installed. Try it as-is first, and be sure to put this ABOVE any of WordPress's rewrite rules. The "L" in the rule means "Last" and when Apache hits that rule, it stops reading .htaccess. WordPress has L rules itself. I've added the extra detail to the answer. –  Matt Van Andel Mar 3 '13 at 15:49
1  
Example: RewriteRule banana-is-great http://www.example.com/bananas-are-great/ [R=301,L] –  Matt Van Andel Mar 3 '13 at 15:56
    
Awesome! I'll try it in a minute! My htaccess file is quite big. I pasted the last part of it into my question. Above that there's a lot of other things. Where should I put the rewrite code? Also it looks like redirection is enabled. :) –  japanworm Mar 3 '13 at 16:12
    
Without seeing the whole thing, I'd recommend that you place it at the very top of your .htaccess - after all, since you are redirecting to another page right off the bat, there's no reason to let Apache do anything else. –  Matt Van Andel Mar 3 '13 at 16:15

When you change individual post permalinks (NOT permalink structure), WordPress saves these old permalinks as post meta data under the key _wp_old_slug and automatically 301 redirects them to the new permalink, no additional work is necessary on your part.

EDIT- also, for future reference, use the shortlink to link posts internally, those will never change even if the slug changes.

share|improve this answer
    
I understand that, but like I said I have a lot of links to the posts I want to change, so redirecting is the only option I have. I didn't know that you could use a shortlink instead. Is there an easy and short way to do that when writing a post in Wordpress? Usually you hit the "URL" button and you can browse your posts and it will automatically give you the link (slug) and the title. If I want to use the shortlink of a post, is my only chance to go to that post, edit and copy the shortlink? –  japanworm Mar 3 '13 at 17:00
2  
redirecting in htaccess or letting WordPress do the redirection is functionally identical, the result is exactly the same. to insert short links via the link to existing content function, see this answer. –  Milo Mar 3 '13 at 17:06
    
Thank you very much! Great for future reference! :) –  japanworm Mar 3 '13 at 17:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.