1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How can I redirect all posts to a corresponding product page?

Discussion in 'Blogging' started by 7 Zulu, Sep 19, 2011.

  1. 7 Zulu

    7 Zulu Newbie

    Joined:
    Jan 14, 2011
    Messages:
    26
    Likes Received:
    6
    Home Page:
    Hi friends :)

    I want to try something a little over my head.

    I have a test site in wordpress, and I want to redirect every post to a product page, and it simply involves substitution, so I am thinking a wordpress plugin using regex?

    It would be very simple, for example, if my permalink contains:

    rubber-ducky

    I would like to change the url that I am linking to within my own site to:

    shop.php?k=rubber-ducky

    Is there a plugin for this?

    And yes, I know this is not a good way to make a website, this is just experimental :D
     
  2. mutatedllama

    mutatedllama Regular Member

    Joined:
    Feb 8, 2011
    Messages:
    445
    Likes Received:
    462
    Possible PHP solution:

    PHP:
    <?php 
    if ($_SERVER['REQUEST_URI']=='rubber-ducky' ) {
    header'Location: shop.php?k=rubber-ducky' ) ;
    } elseif (
    $_SERVER['REQUEST_URI']=='some-other-keyword' ) {
    header'Location: shop.php?k=some-other-keyword' ) ;
    } elseif (
    $_SERVER['REQUEST_URI']=='yet-another-keyword' ) {
    header'Location: shop.php?k=yet-another-keyword' ) ;

    ?>
    Place it before all html in the header section of Wordpress editor.

    Not sure if this works because I'm tired but you may as well test it and see.
     
    • Thanks Thanks x 1
    Last edited: Sep 19, 2011
  3. IGotta

    IGotta Junior Member

    Joined:
    Aug 27, 2010
    Messages:
    105
    Likes Received:
    41
    Occupation:
    Entrepreneur
    Location:
    Earth
    Very Nice! Has anyone tested this to see if it works?^^^^