문제

This is my input url

site.com/?product-43049-keep-kids-filet-children-shoe

I want it to redirect into this

site.com/productDetail.php?id=43049

I have already tried the following code but it doesn't work:

RewriteRule ?product-(.*)-(.*) productDetail?id=$1 [NC,QSA,L]
도움이 되었습니까?

해결책

You cannot match query string in RewriteRule you need to use RewriteCond with %{QUERY_STRING} variable:

Try this code:

RewriteCond %{QUERY_STRING} ^product-([0-9]+)- [NC]
RewriteRule ^/?$ /productDetail.php?id=%1 [L,QSA]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top