I want to setup 301 redirects for requests from: /category/groceries-and-everyday/household/
Redirecting them to: /category/household/
I have the following rules set up for these requests:
# The following is to redirect old urls
RedirectMatch 301 ^/category/groceries-and-everyday/household/$ /category/household/
# This is our rewrite rule for SEO friendly URLs
RewriteRule ^category/(.*)/$ /category_pages/category.php?category_string=$1&rewrite=1 [NC,QSA]
Now when I load /category/groceries-and-everyday/household
I get bounced to: /category/household/?category_string=groceries-and-everyday/household&rewrite=1
I want this to bounce only to: /category/household/
Can somebody please explain why this behaviour is occurring and what changes I should make to achieve my desired result.
Many thanks
3
Answers
Slight adaption on Starkeen's answer.
Changing the second htaccess rule to have the following rewrite condition appears to work.
Can you try placing the 2nd rule before the 1st rule? Basically switch them.
You need to exclude the uri category/household from your rule :
otherwise your rewrite pattern ^category/(.*)/$ will also rewrite it to /category_pages/category.php?category_string=$1&rewrite=1