Results 1 to 7 of 7

Thread: Protecting a Page

  1. #1
    Join Date
    Aug 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Protecting a Page

    I am trying to protect a page from being accessed from any other page other than one. How can I do this?


    I have tried This:


    <script>
    <!--

    //specify valid referrals for script to accept
    //if you wish an entire domain to be valid, enter that (ie: "google.com")
    var validreferrals=new Array()
    validreferrals[0]="my_page.htm"
    validreferrals[1]="my_page.htm"

    var passed=0

    for (r=0;r<validreferrals.length;r++){
    if (document.referrer.indexOf(validreferrals[r])!=-1){
    passed=1
    break
    }
    }

    if (passed==0){
    alert("Access to the page denied!")
    history.go(-1)
    }

    //-->

    </script>

    But It Doen't Work!

    Help! Anyone?
    Last edited by legomind; 08-25-2005 at 12:42 PM.

  2. #2
    Join Date
    Aug 2004
    Location
    Brighton
    Posts
    1,563
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    You really want to do this server-side.

    Add this to your .htaccess file and change as necessary :

    Code:
    # Prevent offsite links to download.htm
    SetEnvIfNoCase Referer ^http://www\.your-domain\.com local
    SetEnvIfNoCase Referer ^http://your-domain\.com local
    SetEnvIf Referer ^$ local
    
    <Files ~ "download\.htm$">
    order deny,allow
    deny from all
    allow from env=local
    </Files>
    cr3
    A retired member, drop me a line through my site if you'd like to find me!
    cr3ative media | read the stickies

  3. #3
    Join Date
    Aug 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I am new to this sort of thing. .htaccess?

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    A file in the folder called .htaccess.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Aug 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I see, I make a foler named .htacces and put what type of file in it?
    Last edited by legomind; 08-25-2005 at 01:22 PM.

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    No, you make a file called .htaccess in the folder with your files and put the above text in it. Although you might want to use ^download\.htm$ not download\.htm$.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Aug 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I can't use .htaccess with free web space!
    Last edited by legomind; 08-25-2005 at 03:20 PM.

Bookmarks

Posting Permissions

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