Immutable Brick
Immutable Brick

Reputation: 820

htaccess rewrite match numbers with names

I have to redirect a broken link so I went to many redirect generation tools to do it but none of them seem to work.

found out special chars do not work

code below:

Redirect 301 /pages/view-colours/view.php?collection=cottage-garden&colour=fallen-fruit http://www.mynewdomain.com/en-GB/collections/cottage-garden/m/product/view/5/preserve-elements

Now I read the answer above but the problem is that the old link had the name of the product and the new system uses the id instead (view/5)

This has to be done in .htaccess, Is there anyway I can create something like an array to match numbers with names and then create a general rule that will redirect every product? or do I have to create a rewrite rule for every single product? (there are many products so I really don't want to be doing this)

Upvotes: 1

Views: 60

Answers (1)

Howli
Howli

Reputation: 12469

Try this it should work for you:

RewriteEngine On 
RewriteCond %{THE_REQUEST} ^(GET|POST)\ /pages\/view-colours\/view\.php\?collection=cottage-garden&colour=fallen-fruit\ HTTP 
RewriteRule ^ http://www..mynewdomain.com/en-GB/collections/cottage-garden/m/product/view/5/preserve-elements [R=301,L] 

Upvotes: 1

Related Questions