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

Need your help! Redirect PHP script

Discussion in 'PHP & Perl' started by Brendo, Mar 6, 2013.

  1. Brendo

    Brendo Regular Member

    Joined:
    Aug 20, 2012
    Messages:
    384
    Likes Received:
    160
    Hello guys,
    I'm trying to find out how to create php redirect script, which to look for particular keyword and then to redirect the user to the desired file. I want to hide the location of the file, that's why I need this script and I'm a total noob in coding. I have around 40 files, which I want to hide using this script. I'd be really thankful if you guys give me some code or at least give me some directions how to do it myself. Thank you!
     
  2. nbphuoc

    nbphuoc Regular Member Premium Member

    Joined:
    Aug 28, 2011
    Messages:
    237
    Likes Received:
    359
    Occupation:
    Selling Twitter Followers
    Location:
    Botting World
    Home Page:
    Use this if you want to redirect user:
    header("Location: __PATH_TO_YOUR_FILE");
    Use some if else condition to determine the path.
    Then you are done :)
     
    • Thanks Thanks x 1
  3. Brendo

    Brendo Regular Member

    Joined:
    Aug 20, 2012
    Messages:
    384
    Likes Received:
    160
    Thank you! I've done what I wanted. I check the referrers and then redirect to the appropriate files.
     
  4. soul4o

    soul4o Newbie

    Joined:
    Mar 6, 2013
    Messages:
    14
    Likes Received:
    2
    You can also user preg_match to find a specific word.
     
  5. stfuplease

    stfuplease Newbie

    Joined:
    Jun 25, 2013
    Messages:
    20
    Likes Received:
    24
    In my experience, unless you need something specifically offered by regular expressions: it's quicker and more efficient to use strstr() or other functions like it (e.g. strpos/stripos).
     
  6. Repulsor

    Repulsor Power Member

    Joined:
    Jun 11, 2013
    Messages:
    712
    Likes Received:
    267
    Location:
    PHP Scripting ;)
    True. Things like this should be done with simple string functions like strpos. Regex, preg_match,ereg_match is an overkill unless you are filtering a junk with some expressions.