• Hi, so I’m trying to redirect a category and all it’s posts to point to my new category url. I used the code below which directed mywebsite.com/category1 to mywebsite.com/category2, but if I click on any old posts such as mywebsite.com/category1/post it doesn’t redirect to mywebsite.com/category2. I’m sure I have used the code below to achieve this before so I’m a bit confused!

    RewriteRule ^category-number-1(.*) http://www.mywebsite.com/category-number-2/$1 [R=301,L]

Viewing 11 replies - 1 through 11 (of 11 total)
  • Moderator Kathryn Presner

    (@zoonini)

    Dumb question, but did you turn on the rewrite engine? i.e. do you have this in your htaccess file somewhere before the rewrite rule?

    RewriteEngine on

    Also, try adding a slash after category-number-1 so it’s

    ^category-number-1/(.*)

    Thread Starter The Night Fox

    (@the-night-fox)

    RewriteEngine on is already in my .htaccess and I had also added the ‘/’ after category-number-1 but still no luck! I keep getting:

    “error 310 too many redirects”

    I can’t understand why though?

    Moderator Kathryn Presner

    (@zoonini)

    Ah – can you post the entirety of your .htaccess in a Pastebin so we can take a look?

    Do you have any redirection plug-ins active as well?

    Thread Starter The Night Fox

    (@the-night-fox)

    Hey zoonini, thanks for the quick reply, really appreciate the help!

    I am running no category base, which if you are not familiar with removes “category” from wordpress URLs. However as you can see, I have a number of other rewrites that are using the same syntax as above and they are working fine!

    http://www.videogamecoupons.org/direct2drive-promo-code/ is correctly redirecting to http://www.videogamecoupons.org/gamefly-coupon but if I click an old post in my blogroll that was filed in the category “direct2drive promo code” it returns the above error.

    http://pastebin.com/QKjxUQCv

    Moderator Kathryn Presner

    (@zoonini)

    Can you give me one of the bad links? I’m looking through your sidebar but can’t find it and I’m not sure I’m looking in the right place. Thanks.

    Thread Starter The Night Fox

    (@the-night-fox)

    If you click the first link on the page below you will see the error…

    http://www.videogamecoupons.org/page/26/

    Moderator Kathryn Presner

    (@zoonini)

    Ah – I see what you mean but unfortunately I can’t see a reason for the issue.

    Have you tried playing with the order of the redirects? i.e. putting the one for the problematic category above the others?

    Do you have a lot of posts in that one problematic category – perhaps it would be quicker to just reassign them to the new category using the bulk tool, and remove the redirect?

    Moderator Kathryn Presner

    (@zoonini)

    One more thing – I checked the headers being issued by that link using this tool and the browser is receiving the correct “301 moved” headers:

    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
    <html><head>
    <title>301 Moved Permanently</title>
    </head><body>
    <h1>Moved Permanently</h1>
    <p>The document has moved <a href="http://www.videogamecoupons.org/gamefly-coupon/75-off/">here</a>.</p>
    <hr>
    <address>Apache Server at www.videogamecoupons.org Port 80</address>
    </body></html>

    …however it’s this page that is causing the infinite loop somehow:

    http://www.videogamecoupons.org/gamefly-coupon/75-off/

    Still don’t know why, but perhaps it’s a clue – as it looks like your category1/post -> category2/post redirect is actually itself working fine.

    Moderator Kathryn Presner

    (@zoonini)

    Ah, OK, now we’re getting somewhere. I put the second URL –

    http://www.videogamecoupons.org/gamefly-coupon/75-off/

    – into the same tool as above, and now it shows that it’s being redirected back to

    http://www.videogamecoupons.org/direct2drive-promo-code/75-off/

    …which of course causes an infinite loop.

    Again, not sure why this is happening but I would likely go the category reassignment-route as the easiest solution.

    Thread Starter The Night Fox

    (@the-night-fox)

    Thanks for the input, I’m going to play around with the order and see what happens. I don’t want to reassign them to a new category as there are a lot of posts and from an SEO standpoint it’s a pretty bad idea!

    Moderator Kathryn Presner

    (@zoonini)

    Good luck – let me know if you figure it out.

    You didn’t mention how many posts are in that category, but if there aren’t that many, as a last resort you could add simple redirects for each of them if they work better than the category-wide Regex rewrite. i.e.

    Redirect 301 /old-cat/slug/ http://www.videogamecoupons.org/new-cat/slug/

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Can any .htaccess experts figure this out?’ is closed to new replies.