Htaccess重定向特定页面和查询字符串变量

I'm trying to do a redirect with a .htaccess file matching these specific requirement:

  1. The page/script name is foo.php
  2. The querystring must contain p=1
  3. There could be any number of other querystring variables present

If these conditions are met, you should be redirected to: /new-url/

This is what I've come up with that doesn't work. It matches and redirects /foo.php but not /foo.php?p=1 or /foo.php?p=1&x=5

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} ^foo\.php$ [NC]
RewriteCond %{QUERY_STRING} (^|&)p=1(&|$) [NC]
RewriteRule . new-url/? [R=301,L]

Thanks very much in advance for any assistance!

Can you try:

RewriteCond %{QUERY_STRING} (^|&)p=1(&|$) [NC]
RewriteRule (^|/)foo\.php$ /new-url/? [R=301,L,NC]

Also test it in a different browser to avoid browser caching issues due to R=301