I have some predefined links that I need to redirect to real URLs within my WP install. I have NO CHOICE but to use these URLs provided to me, unfortunately. The format is:
http://mysite.com/redirect.html?p=pagename
WP is installed at the root of mysite.com. I need to take the pagename query var, which will not be a direct match to a page URL and redirect it (301) to a WP permalink. I have attempted a few things in .htaccess with rewrites but not having luck mostly due to the fact that there are also WP permalinks redirecting.
Anyone done this before or know the best approach?
UPDATE - Here is the working code that I used based on the accepted answer below:
RewriteCond %{REQUEST_URI} ^/redirect.html(.*)$
RewriteCond %{QUERY_STRING} ^(.*?)&?p=page&?(.*?)$
RewriteRule (.*) /page/?%1&%2 [L,R=301]
I also added these before the base WP rewrites.
RewriteRule ^redirect\.html$ /perma-link [R=301]