pomaaa
pomaaa

Reputation: 615

How to create a 301 redirect for new product URL in htaccess

I have the following problem.

My website has changed the CMS and the product URLS are different. They used to look like this:

domain.com/old-link/?a1=291&b2=23&c3=92

The new one however looks like this:

domain.com/new-one/291-23-92

How can I create a redirect for all products that look like that using .htaccess?

Upvotes: 1

Views: 78

Answers (1)

Amit Verma
Amit Verma

Reputation: 41219

You can use the following rule :

RewriteEngine on


RewriteCond %{THE_REQUEST} /old-link/\?a1=([^&]+)&b2=([^&]+)&c3=([^&]+)\sHTTP [NC]
RewriteRule ^ /new-link/%1-%2-%3? [L,R]

Upvotes: 1

Related Questions