The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

redirect on dynamic pages

Discussion in 'General Discussion' started by theengel, Jul 25, 2006.

  1. theengel

    theengel Registered

    Joined:
    Feb 9, 2005
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    I run an OScommerce site. I want to be able to redirect traffic when someone clicks on a certain product...like when it's sold out.

    for example, when someone tries to click "domain.com/product_info.php?cPath=37&products_id=84" I want it to go to "another_domain.com"

    But when I set up the redirect, it takes all of the traffic from "domain.com/product_info.php" and forwards it to the site.

    Please help...is there eve a way to do it?
     
  2. Izkabola

    Izkabola Well-Known Member

    Joined:
    Aug 5, 2003
    Messages:
    58
    Likes Received:
    0
    Trophy Points:
    6
    Please note, the is a forum for cPanel support not oscommerce.

    I don't understand how you are doing the redirects, however make sure that the http:// is present (ex: http://www.domain.com). Without the http://, the software (unless coded to do otherwise) will turn it to http://www.domain.com/newdomain.com. Since that directory doesn't exist, it may send you back to the default product page. Just a thought.
     
  3. theengel

    theengel Registered

    Joined:
    Feb 9, 2005
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Yes, I made sure of that...I was using the 'redirect' button from cpanel.

    So far, it looks like I'll have to set up something in php to do it...unless someone has an idea.

    I also tried editing the htaccess file, where I could make sure that it got the filename and the variable data. But then it wouldn't redirect that page at all...it just ignored my command.
     
  4. hostmedic

    hostmedic Well-Known Member

    Joined:
    Apr 30, 2003
    Messages:
    559
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Washington Court House, Ohio, United States
    cPanel Access Level:
    DataCenter Provider
  5. dbanach

    dbanach Member

    Joined:
    Jun 8, 2006
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Is it possible to redirect dynamic url's with in Cpanel using Cpanel's redirect? Most of the pages on my sites are of the form

    domain/page.php?id=123

    When I try to redirect
    domain/page.php?id=123
    to
    domain/destinationpage.htm

    all requests to domain/page.php, not just those with id=123, are redirected.
     
  6. nickp666

    nickp666 Well-Known Member

    Joined:
    Jan 28, 2005
    Messages:
    770
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    /dev/null
    you would need to add a header location command in the PHP script

    Code:
    <?php
    if ($_GET[var] == "123") {
         header("Location: http://www.domain2.com/file.php?var=$_GET[var]");
    }
    ?>
    
    (Dont forget to clean the GET variables before you use them though ;))

    EDIT: If you have loads of products use a Switch statement with case clauses otherwise you will have tons of un-needed code

    Code:
    <?php
    
    switch ($_GET[var]) {
          case "100":
              header("Location: http://www.domain2.com/file.php?var=100");
          break;
    
          case "200":
              header("Location: http://www.domain2.com/file.php?var=200");
          break;
    }
     
    #6 nickp666, Aug 7, 2006
    Last edited: Aug 7, 2006
  7. dbanach

    dbanach Member

    Joined:
    Jun 8, 2006
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    nickp666,

    Thanks so much! After fiddling with .htaccess files this was soo easy!

    I did add a
    header("HTTP/1.1 301 Moved Permanently");

    to make it more search engine friendly.

    My only problem now will be re-adding all the redirects when I update the site php files.

    Thanks again for the help!
     
  8. nickp666

    nickp666 Well-Known Member

    Joined:
    Jan 28, 2005
    Messages:
    770
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    /dev/null
  9. davper

    davper Registered

    Joined:
    Aug 7, 2003
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Is there someway of redirecting on a larger scale? Example:
    http://www.domain2.com/file.php?var would be redirected and
    http://www.domain2.com/file.php?newvariable would not be redirected
     
  10. nickp666

    nickp666 Well-Known Member

    Joined:
    Jan 28, 2005
    Messages:
    770
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    /dev/null
    please elaborate a little on what you mean by 'on a larger scale'

    the above mentioned method will work for what you added in your post.

    e.g.
    PHP:
    <?php

    switch ($_GET[var1]) {
         case 
    "20":
              
    // do something
         
    break;
    }
    // if var1 doesnt have any of the values in the switch or isnt defined, will get to here

    ?>
     
  11. theengel

    theengel Registered

    Joined:
    Feb 9, 2005
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    It looks like the main point of this thread is that CPANEL will NOT redirect a dynamic page to another site.

    I have figured out the code to get OScommerce to redirect to another specified site when the product count = 0 (sold out) and when I specify another webpage. I also put a spot in the admin area to specify a redirect page for each product. I'll post it here later, in case anyone is interested.

    But I beleive I'm taking unnecessary steps in the process because I just rearranged some code from another part of another script.
     
Loading...

Share This Page