Reputation: 313
Trying to do some 301 rewrites but an urls string is appended..
I think this is happening because I'm using a SEO rewrite and 301 redirect on top? Any suggestions on how to fix this would be highly appreciated!
The problem is:
This URL: domain.nl/meubels/Tafels/Theetafels-en-wijntafels/
Should be rewritten to: domain.nl/meubels/tafels/theetafel-wijntafel/
But it's rewritten to: domain.nl/meubels/tafels/theetafel-wijntafel/?activetab=Tafels&cat=Theetafels-en-wijntafels
Where this should not be added to the URL: ?activetab=Tafels&cat=Theetafels-en-wijntafels
My htaccess file:
ErrorDocument 404 /error404.php
RewriteRule ^meubels/$ product-listing.php?show=home
RewriteRule meubels/(.*)/(.*)/(.*)/$ product-listing.php?activetab=$1&cat=$2&open=$3
RewriteRule meubels/(.*)/(.*)/$ product-listing.php?activetab=$1&cat=$2
RewriteRule product/(.*)/$ product-detail.php?id=$1
RewriteRule info/(.*)/$ text-page.php?show=$1
RewriteRule info/(.*)/$ text-page.php?show=$1
# DirectoryIndex product-listing.php?cPath=32
Redirect 301 /meubels/Tafels/Theetafels-en-wijntafels/ /meubels/tafels/theetafel-wijntafel/
Upvotes: 1
Views: 113
Reputation: 5905
.htaccess works in vertical order down the page, so if you move your 301 to above the rewrite rules for meubels, then it will redirect and then show the parametised meubels page on the friendly url.
ErrorDocument 404 /error404.php
Redirect 301 /meubels/Tafels/Theetafels-en-wijntafels/ /meubels/tafels/theetafel-wijntafel/
RewriteRule ^meubels/$ product-listing.php?show=home
RewriteRule meubels/(.*)/(.*)/(.*)/$ product-listing.php?activetab=$1&cat=$2&open=$3
RewriteRule meubels/(.*)/(.*)/$ product-listing.php?activetab=$1&cat=$2
RewriteRule product/(.*)/$ product-detail.php?id=$1
RewriteRule info/(.*)/$ text-page.php?show=$1
RewriteRule info/(.*)/$ text-page.php?show=$1
# DirectoryIndex product-listing.php?cPath=32
The first time it looks at htaccess it will redirect on the 301 straight, then the second time it will skip that and serve the rewrite. If that doesn't work try RewriteEngine On
above your rewrite rules.
Upvotes: 1
Reputation: 19380
RewriteRule ^meubels/Tafels/Theetafels-en-wijntafels/ http://domain.nl/meubels/tafels/theetafel-wijntafel/ [R=301,L]
And like @Liam Bailey said, it should be on top, before other rewrite rules.
Upvotes: 2