Forum Topic: Redirecting URLs that start with &mc

Forum: .htaccess Forum : Redirecting • Posted by Brin Wilson • Updated:

Hi all,

Any idea how to redirect any incoming URLs that start with

&mc_cid=b4c0302253&mc_eid

to my home page.

For example:

http://mysitedomainurlhere.com/&mc_cid=b4c0302253&mc_eid=i88a0a40ca
http://mysitedomainurlhere.com/&mc_cid=b4c0302253&mc_eid=d88dfvacae
http://mysitedomainurlhere.com/&mc_cid=b4c0302253&mc_eid=dfyucd

etc

I've tried:

redirect 301 ^/&mc_cid=b4c0302253&mc_eid http://mysitedomainurlhere.com

But no luck...

Thanks,
Brin

5 Replies to “Redirecting URLs that start with &mc”

Posted by Brin Wilson

Just had another crack at this with:

RedirectMatch 301 ^&mc_cid=b4c0302253&mc_eid.* http://mysitedomainurlhere.com

But still no luck... :(

Anyone?

Posted by Brin Wilson

Aha, just guessed at this one:

RedirectMatch 301 /&mc_cid.* http://mysitedomainurlhere.com

...seems to be working...

Does this look right?

Jeff? :)

Jeff Starr
Posted by Jeff Starr

If it works, it works, but one thing that looks kinda odd is the format of the URL:

http://mysitedomainurlhere.com/&mc_cid=b4c0302253&mc_eid=i88a0a40ca

Normally parameters such as mc_cid are included in URLs via query string, which would look like this:

http://mysitedomainurlhere.com/?mc_cid=b4c0302253&mc_eid=i88a0a40ca

Such that a question mark is used to distinguish the first parameter, and then any additional parameters are added via ampersand (or even better encoded ampersand)..

So in this case, I just wonder if the URLs are written as intended.. as far as I know scripts only recognize query string parameters when passed via question mark.

Just my thoughts on it :)

Posted by Brin Wilson

Thanks Jeff,

Sadly those (varying) incoming URL formats are entirely out of my control.

Given that, is my solution the one you'd use (I'm such a beginner at this) or can you suggest a better alternative?

Really pleased to be able to use this forum by the way - really nice of you to have made it accessible to folk like me! ;)

Brin

Jeff Starr
Posted by Jeff Starr

It depends on whether or not your site also is using the same parameters. If not, then something like this would be keen:

RedirectMatch 301 (?i)&mc_cid http://mysitedomainurlhere.com

That will redirect any request containing &mc_cid to the homepage. Let me know if that works, or if more refinement is needed, glad to help!