Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
    
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? –  Rutwick Gangurde Nov 9 '11 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 Nov 9 '11 at 18:28

1 Answer 1

up vote 2 down vote accepted

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.

share|improve this answer
    
where would I add this rule? –  Corey Hart Nov 10 '11 at 17:34
    
Add it to functions.php. Then go to Settings > Permalinks, and just hit the save button. –  Rutwick Gangurde Nov 11 '11 at 2:48
    
...works, thanks –  Corey Hart Nov 13 '11 at 6:52
    
Great! You're welcome! –  Rutwick Gangurde Nov 13 '11 at 14:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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