简体   繁体   中英

.htaccess get after ? (Question Mark)

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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM