문제

I am using the following code to attempt to redirect a dynamic URL to a new dynamic URL, under the same domain:

RewriteRule ^products/item/^\d([^/]+) /product/$1/ [R=301,L]

I've tried these too:

RewriteRule ^products/item/[^\d]([^/]+) /product/$1/ [R=301,L]
RewriteRule ^products/item/[0-9]([^/]+) /product/$1/ [R=301,L]

But this was redirecting /products/item/342/ to /product/42/, I tested this on a larger number (e.g. 123456789) and it redirected to /product/23456789/.

It would appear that my rule is not picking up the firsts digit, can anyone help me resolve this?

I've also tried using [\d] instaled of [0-9], but this has the same problem.

Cheers!

도움이 되었습니까?

해결책

Try

RewriteRule ^products/item/(\d[^/]+) /product/$1/ [R=301,L]

다른 팁

RewriteRule ^products/item/([0-9]+) /product/$1/ [R=301,L]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top