We help IT Professionals succeed at work.

redir code

XK8ER
XK8ER asked
on
Hello there,
I whould like to edit this code, is working fine but Im looking for something shorter..

if (isset($_SERVER['QUERY_STRING']) ) {
     switch( $_SERVER['QUERY_STRING']) {
          case "YdcN6eDAj6xB":
                       header ("Location: http://www.aol.com");
                       exit;

          case "hXzRz35YszHA":
                       header ("Location: http://www.yahoo.com");
                       exit;

     }
}



I would like something like this


if (isset($_SERVER['QUERY_STRING']) ) {
     switch( $_SERVER['QUERY_STRING']) {
          case "YdcN6eDAj6xB" or "hXzRz35YszHA" or "zpgcAQoNMu8S":
                       header ("Location: http://www.aol.com");
                       exit;
     }
}


is it possible?
Comment
Watch Question

Commented:
you could do this:

if (isset($_SERVER['QUERY_STRING']) ) {
     switch( $_SERVER['QUERY_STRING']) {
          case "YdcN6eDAj6xB": case "hXzRz35YszHA": case "zpgcAQoNMu8S":
                       header ("Location: http://www.aol.com");
                       exit;
     }
}
Top Expert 2007
Commented:
See http://www.php.net/manual/en/control-structures.switch.php
if (isset($_SERVER['QUERY_STRING']) ) {
     switch( $_SERVER['QUERY_STRING']) {
          case "YdcN6eDAj6xB":
          case "hXzRz35YszHA":
          case "zpgcAQoNMu8S":
                       header ("Location: http://www.aol.com");
                       exit;
     }
}

Open in new window

CERTIFIED EXPERT

Commented:

Explore More ContentExplore courses, solutions, and other research materials related to this topic.