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 changed our "category base" in WP settings from the default "category" to "customname".

Now there are 404 errors to links containing the old category slug eg. mysite.com/category/names

What do I enter in .htaccss to 301 redirect

mysite.com/category/xxx

to

mysite.com/customname/xxx

Thanks,

share|improve this question

2 Answers 2

Htaccess is your friend in this case. You can create 301 form your old category base to the new like so:

RewriteEngine on
RewriteBase /
RewriteRule ^old_dir/(.*) http://www.example.com/new_dir/$1 [R=301,L]

Change old_dir to category example.com to your domain and new_dir to your custom name.

Hope this helps. Ohad.

share|improve this answer
    
this almost works. It redirects "everything" to: example.com/new_dir So for example example.com/old_dir/news is redirected to example.com/new_dir but instead it should redirect to example.com/new_dir/news What should be changed? thx –  Hayden Feb 6 '11 at 11:21
    
yep' my bad i updated the code. –  Bainternet Feb 6 '11 at 11:45
    
yea nice edit lol! you win buddy. cheers –  Hayden Feb 6 '11 at 13:08

Ok by Googling (which I was doing for hours before posting here) I found the answer! But this time I googled the beginning part of your suggested rewrite rule:

RewriteRule ^olddir/

which resulted in finding the answer here which is:

RewriteRule ^olddir/?(.*)$ newdir/$1 [R=301,L]

hope this helps someone else. Now just need to find the rewrite rule for: How to? Redirect /category/sci-fi/ to /category/scifi/?

thx

share
locked by EAMann Mar 8 '11 at 15:09
    
the same way. RewriteRule ^sci-fi/?(.*)$ scifi/$1 [R=301,L] –  Bainternet Feb 6 '11 at 11:53
    
Why did you vote down my answer? No it's not the same way because the URL is site.com/category/scifi NOT site.com/scifi. –  Hayden Feb 6 '11 at 12:17
    
what???? whats RewriteRule ^sci-fi/?(.*)$ scifi/$1 [R=301,L] got to do withthe vote down? its for the answer with the same code as mine 3 minutes after i posted it. sorry but if you feel that bad edit your answer and i'll remove the vote –  Bainternet Feb 6 '11 at 12:43
    
I'm only trying to help you buddy. –  Bainternet Feb 6 '11 at 12:44
    
The code you posted dumped everything to ONE absolute location. Thus why I searched and found the correct code that changes the /dir/ page of the url ONLY and so posted I it and source. Thus, I see no reason to vote down my answer when the code I posted does something different. –  Hayden Feb 6 '11 at 12:58

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.