Forum

Thread tagged as: Question, Configuration

.htaccess and Rewrites

Not a Perch specific question but wondering if anyone can help me.

In layman's terms i.e non regex guru

How do I redirect the following URL with a query string. I've read up on rewrite rules and have my rewrites working as well as 100's 301 of rewrites working on this site, but this one is baffling me, I only want to redirect specific URLs that may contain query string variables as per this example.

Redirect 301 /my-booking-url?charity=Positive%20Action%20on%20Cancer https://www.my-site.com/why-we-hear-you

My current rewrite rules look like so

RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

Any help / explanation would be greatly appreciated.

Many thanks

Lee

Lee Goodman

Lee Goodman 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

I think you can use RewriteCond %{QUERY_STRING} maybe something like

RewriteCond %{QUERY_STRING} ^charity=Positive%20Action%20on%20Cancer
RewriteRule ^my-booking-url /why-we-hear-you [R=301,L]