7

I'm doing a bit of AB testing, and am looking for a way to point multiple endpoints to the same page in wordpress. My site is using wordpress as it's CMS tool.

http://mysite.com/test/link1
http://mysite.com/test/link2
http://mysite.com/test/link3

I want the above URL's to point to the about page generated through wordpress

http://mysite.com/about

The specific use case is to track hits through google analytics. I've tried doing 301 redirects, but searching through referrers for your site doesn't always work. Any idea's?

2
  • A custom permalink rewrite will work for you. Do you want all the urls ending with link<xyz> to point to the same about page, and always? Commented Nov 9, 2011 at 5:07
  • How would you go about doing that? I already have a custom permalink setting in the admin page. And yes, always point to the about page content, but keep the link<xyz> path
    – Corey Hart
    Commented Nov 9, 2011 at 18:28

1 Answer 1

5

Okay... here's how you add the rule.

<?php
    add_action('init', 'add_my_rule');

    function add_my_rule()
    {
        add_rewrite_rule('^test\/link.*$','index.php?pagename=about','top');
    }
?>

This rule will ensure that when you visit a url like http://.../test/link or http://.../test/link<xyz>, you are redirected to the about page (please make sure the slug for about page is 'about'). Also, http://.../test/, will take you the test page and not the about page.

Let me know if this works for you.

2
  • 2
    where would I add this rule?
    – Corey Hart
    Commented Nov 10, 2011 at 17:34
  • 2
    Add it to functions.php. Then go to Settings > Permalinks, and just hit the save button. Commented Nov 11, 2011 at 2:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.