Stand by...

Make Money Online blog


How To Do A Conditional 301 Redirect?

I have a wordpress site (php/apache) .
I need to create a 301 “wildcard” redirect – I think I can add it to my htaccess file. Here is what I need to do :
I have some affiliate links that look like this:http://mydomain.com/page-topic/?utm_sour…
utm_medium=website&utm_campaign=your email
/?utm_source=
will always be
/?utm_source=
Everything after /?utm_source= will vary.
I want to setup a redirect- for any URL that contains http://mydomain.com/page-topic/?utm_sour…
redirected to my homepage- http://mydomain.com/
——-
Once working properly I should be able to visit:http://mydomain.com/page-topic/?utm_sour…
utm_medium=blah&utm_campaign=whatever
should redirect to http://mydomain.com
————-
Lastly- I would love to have this be conditional – and only apply to all search engines- but if that is not possible- a reidrect for all

1 Comment(s). Add a comment or Trackback

  • Web Design Midlands  03:59 Dec 14, 2009 

    In your .htaccess file this should redirect everything to your home page.
    RewriteRule ^page-topic/?utm_source=(.*)$ http://mydomain.com/ [L,R=301]
    Haven’t tested it though but think it’ll work.
    Regards
    Web Design Midlandshttp://www.webdesign-midlands.co.uk

Comments are closed.