#1
  1. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Mar 2008
    Posts
    769
    Rep Power
    41

    Redirection without a refferer script


    Hi, I have client who would like a specific url, which would bring the viewer to a landing page. For example I have www.client.com/product
    When this link is entered, the viewer would be taken to www.client.com/landing.php

    Is this possible without a referrer script? I have seen this on the internet, but I am unfamiliar with it.

    If possible, would this be done in PHP or JavaScript?

    Thanks
  2. #2
  3. User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2005
    Location
    UK
    Posts
    471
    Rep Power
    76
    So you want a redirection script?
    PHP Code:
    header("Location:here.php"
    Good enough?

    JS:
    Code:
    window.location = 'Where to.php'
    HTML:
    Code:
    <META HTTP-EQUIV="Refresh" CONTENT="5; URL=redirect.php">

    Comments on this post

    • JavaNinja agrees
  4. #3
  5. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,304
    Rep Power
    7174
    Don't program anything that relys on the referrer. If you want them to have to visit the landing page first (which I don't recommend), then use a cookie instead. Set the cookie once they visit the landing page, on the other pages check to see whether the cookie exists or not when you decide whether to redirect them or show them the pages' content.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2008
    Posts
    2
    Rep Power
    0
    When I'm in a hurry, I normally do this the same way sephers mentioned using the javascript method. It won't redirect people if they have javascript disabled though.

    A better option would be to use the mod_rewrite apache module. This way the client still sees the friendly url "/product" in their browser, but the server will load the "landing.php" content. It's also server side, so it will work for all visitors.

    Try adding this to the .htaccess file of the base public directory

    RewriteEngine On
    RewriteRule ^product$ landing.php [L]

IMN logo majestic logo threadwatch logo seochat tools logo