0

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,

10

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.

| improve this answer | |
0

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

This is working fine for me.

| improve this answer | |
-1

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

| improve this answer | |
  • 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

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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