theengel

Registered
Feb 9, 2005
3
0
151
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?
 

Izkabola

Well-Known Member
Aug 5, 2003
58
0
156
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.
 

theengel

Registered
Feb 9, 2005
3
0
151
Izkabola said:
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.
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.
 

dbanach

Member
Jun 8, 2006
6
0
151
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.
 

nickp666

Well-Known Member
Jan 28, 2005
769
2
168
/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;
}
 
Last edited:

dbanach

Member
Jun 8, 2006
6
0
151
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!
 

davper

Registered
Aug 7, 2003
1
0
151
nickp666 said:
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;
}
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
 

nickp666

Well-Known Member
Jan 28, 2005
769
2
168
/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

?>
 

theengel

Registered
Feb 9, 2005
3
0
151
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.