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 5 of 5
  1. #1
    New Coder
    Join Date
    Jan 2009
    Posts
    13
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Redirect ALL visitors ALWAYS to index.html

    Hi,

    I am just starting to understand JAVA Script a little bit to the point where I am able to modify scripts. Thing is now I can't find anything similar to what I need to modify

    So maybe someone here can help me with the following:

    I have a page which can be found in google which is nice. But people can find a lot of sub-pages as well which is nice from a PR point of view. Nevertheless I don't want people to jump in the middle. I want them all to start on index.hmtl and nowhere else. So is it possible to have all visitors who click on a search result for example in google to be redirected to index.html ? Maybe referrer based redirect? Can someone help me out on how this is done?

    Thanks in advance. Martin

  • #2
    Senior Coder
    Join Date
    May 2006
    Posts
    1,683
    Thanks
    28
    Thanked 4 Times in 4 Posts
    Although you can do it with js its better to do this on the serverside.

    Provided you have php running on your server
    (and most do), then rename your pages to .php pages

    Now you can use sessions.

    Add this to all the non-index pages:

    PHP Code:
    <?php 
    @session_start();

    if (@
    $_SESSION['auth'] != "yes" ){
         
    header("Location: index.php");
         exit();
    }  
    // end if
    ?>
    then on the index page add:

    PHP Code:
    <?php 
    @session_start();
    $_SESSION['auth'] = "yes";
    ?>
    Of course all your internal links need to be changed to .php as well
    no .htm ot .html can stay - all .php

    OK

  • Users who have thanked jeddi for this post:

    martinrab (01-22-2009)

  • #3
    Senior Coder
    Join Date
    May 2006
    Posts
    1,683
    Thanks
    28
    Thanked 4 Times in 4 Posts
    If you don't want to do the php route
    you can use mod_rewrite rules in your htaccess file.

    But the php route is easier and quicker.

  • #4
    New Coder
    Join Date
    Jan 2009
    Posts
    13
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Hey Jeddi,

    thanks for your reply. I am in way over my head already I guess. For PHP hoes the same as for Java Script as far as I am concerned. I can read the code and modify it but don't really understand it yet. So you are saying that if I rename my fiels to *.php and paste your code in there "as is" all funcitonality will be the same as in my original html files but people are redirected to index? Will try right now! You are a champion!

  • #5
    New Coder
    Join Date
    Jan 2009
    Posts
    13
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Hey Jeddi, your second name is not by coincidence "GOD"? If not you are to me. What a cool solution. This actually now by coincidence solved another problem I had on the way..... THANKS THANKS THANKS!


  •  

    Tags for this Thread

    Posting Permissions

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