I have htaccess code given to me by a program called "Post Affiliate Pro" that looks like this
# Start Post Affiliate SEO Code----
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .? - [S=4]
RewriteRule ^?coupon-code=([a-zA-Z0-9_-]+)\/?$ https://example.postaffiliatepro.com/scripts/l5zhexygnc?a_aid=$1 [R=301,L]
RewriteRule ^?coupon-code=([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)\/?$ https://example.postaffiliatepro.com/scripts/l5zhexygnc?a_aid=$1&a_bid=$2 [R=301,L]
RewriteRule ^?coupon-code=([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)\/?$ https://example.postaffiliatepro.com/scripts/l5zhexygnc?a_aid=$1&a_bid=$2&chan=$3 [R=301,L]
RewriteRule ^?coupon-code=([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)\/?$ https://example.postaffiliatepro.com/scripts/l5zhexygnc?a_aid=$1&a_bid=$2&chan=$3&data1=$4 [R=301,L]
RewriteRule ^?coupon-code=([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)\/?$ https://example.postaffiliatepro.com/scripts/l5zhexygnc?a_aid=$1&a_bid=$2&chan=$3&data1=$4&data2=$5 [R=301,L]
# End of Post Affiliate SEO Code
This breaks my site because the URL I am trying to redirect has a query string at the beginning, like so https://example.com/?coupon-code=PGZ
I know I need to modify it using QUERYSTRING somehow, but I don't know exactly what to do. Can anyone help me modify this htaccess code so it won't break my site?