Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Banned
    Join Date
    Oct 2010
    Posts
    115
    Thanks
    30
    Thanked 0 Times in 0 Posts

    Need help with redirect code. not really sure how to do this...

    I know zero php. I need help with this problem as soon as possible.

    Basically what I need to do is the following:

    if the viewer came from xxrandomxx.com, then this page wouldn't redirect.

    If they came from anywhere else, then I want the page to take them to xxrandomxx.com

    Do any of you have any ideas of how to do this or achieve a similar goal?

    I need to do this because only xxrandomxx.com is password protected and none of the other subfolders/files are, so on google they show up and arent protected but they need to be.

  • #2
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,368
    Thanks
    262
    Thanked 32 Times in 31 Posts
    hi, ok im alittle lost here so if they come from site1 you want to not redirect them, but if they come from anywheres else you want to take them to site1.... ok thats confusing...

    im thinking you dont need php code per say, you need a mod rewrite and some htaccess stuff...

    please clarify

  • #3
    New Coder
    Join Date
    Jun 2010
    Posts
    54
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Try:

    PHP Code:
    <?php
    if ($_SERVER['HTTP_REFERER'] != $_SERVER['SERVER_NAME'])
    {
    header('Location: http://xxdomainxx.com');
    }
    ?>
    Just make sure you have it at the top of your page or it will throw an error. This will make it so if an outside website comes to yours, it will redirect to that main page. I don't know what to say about referrals from within your website. You'll need to start setting some sessions to get that done.

  • #4
    Banned
    Join Date
    Oct 2010
    Posts
    115
    Thanks
    30
    Thanked 0 Times in 0 Posts
    Thanks soneen!

    I havent checked it yet, but it looks good.

    What would I write for server name and header?

    Also what are referrals and sessions?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •