I'm trying to do a redirect with a .htaccess file matching these specific requirement:
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