Can any .htaccess experts figure this out? (12 posts)

  1. The Night Fox
    Posted 4 years ago #

    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]

  2. 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


  3. The Night Fox
    Posted 4 years ago #

    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?

  4. 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?

  5. The Night Fox
    Posted 4 years ago #

    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.


  6. 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.

  7. The Night Fox
    Posted 4 years ago #

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


  8. 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?

  9. 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:

    <title>301 Moved Permanently</title>
    <h1>Moved Permanently</h1>
    <p>The document has moved <a href="http://www.videogamecoupons.org/gamefly-coupon/75-off/">here</a>.</p>
    <address>Apache Server at www.videogamecoupons.org Port 80</address>

    ...however it's this page that is causing the infinite loop somehow:


    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.

  10. Ah, OK, now we're getting somewhere. I put the second URL -


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


    ...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.

  11. The Night Fox
    Posted 4 years ago #

    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!

  12. 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/

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.