简体   繁体   中英

redirect - 301 with dynamic urls and question marks

I have several redirects in my htaccess file like

redirect 301 /detail.php?id=101 http://www.example.com/product/costume-didnt-fit-im-stuck-shirt/

I use this method frequently, but this time it seems to not be working and I am thinking it is the dynamic url. Is there a way to have this method of redirect with this type of URL?

You cannot match query string in Redirect directive. Use mod_rewrite rules instead:

RewriteEngine On

RewriteCond %{QUERY_STRING} ^id=[0-9]+
RewriteRule ^detail\.php$ http://www.example.com/product/costume-didnt-fit-im-stuck-shirt/? [L,R=301,NC]

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