简体   繁体   中英

301 redirect rewriterule not working in apache for article id=3 and id=39

I used RewriteRule for 301 redirect in Apache server - all URLS working except these two:

  1. articles.details.php?recordID=3
  2. articles.details.php?recordID=39
RewriteCond %{QUERY_STRING} recordID=3
RewriteRule ^articles.details\.php$ /festivals-religious/? [L,R=301]

RewriteCond %{QUERY_STRING} recordID=39
RewriteRule ^articles.details\.php$ /festivals-traditional/? [L,R=301]

Both URLs redirected to: /festivals-religious/.

I think conflict with recordID=3 and recoredID=39 , as 3 exists in both URLs.

The problem is that the second RewriteCond also matches the first one. One option would be to add a $ to the end of the first rule, like so:

RewriteCond %{QUERY_STRING} recordID=(3)$
RewriteRule ^articles.details.php$ /festivals-religious/? [L,R=301]

RewriteCond %{QUERY_STRING} recordID=39
RewriteRule ^articles.details.php$ /festivals-traditional/? [L,R=301]

The $ means "the end of this particular query string."

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