Submit Your Article Forum Rules

Results 1 to 5 of 5

Thread: .htaccess resitrict a single file

  1. #1
    Senior Member
    Join Date
    Jul 2003
    Posts
    293

    .htaccess resitrict a single file

    Hello,

    I would like to resitrict the initial access to a single file using .htaccess. I tried through CPanel, but that is for whole directories and I don't have the know how to write this on my own.

    The one file is part of a cart system that steps through the same file 4 times (Product Select, Ship/Bill info, CC info, Order Confirm). I do not want the password to be triggered each step of the way just on the initial page request.

    Is there a way to do this with .htaccess?

    Please advise.

    Thanks

    Rob
    Rob

  2. #2

    Re: .htaccess resitrict a single file

    Quote Originally Posted by ackerley1 View Post
    Hello,

    I would like to resitrict the initial access to a single file using .htaccess. I tried through CPanel, but that is for whole directories and I don't have the know how to write this on my own.

    The one file is part of a cart system that steps through the same file 4 times (Product Select, Ship/Bill info, CC info, Order Confirm).
    I do not want the password to be triggered each step of the way just on the initial page request.

    Is there a way to do this with .htaccess?

    Please advise.
    Rob
    I don't think creating .htaccess would help you for doing so rather you should try it by writing some code for it.

  3. #3
    Senior Member
    Join Date
    Jul 2003
    Posts
    293

    Re: .htaccess resitrict a single file

    Andyf, Could you elaborate any more on this?
    Rob

  4. #4
    WebProWorld MVP wige's Avatar
    Join Date
    Jun 2006
    Posts
    3,138

    Re: .htaccess resitrict a single file

    When you use .htaccess, or more accurately an .htaccess and .htpasswd HTTP Authentication system, to password protect part of your site, the username and password are required each time a page is requested. However, the user's browser will remember the username/password combination and will send the information each time after the initial prompt, which I think is what you are trying to achieve.

    Unfortunately, HTTP Authentication is a per-directory directive. This means you can only specify a directory to be protected, and not a single file. Unfortunately, this protection is done at the system level, so using a rewrite rule would not be a workaround in this case. Probably you would need to reprogram the actual page to request the username and password and store those values in a session variable. Bear in mind that unless this is done via HTTPS, the username and password are transmitted in plain text and thus not very secure.
    The best way to learn anything, is to question everything.
    WigeDev - Freelance web and software development

  5. #5

    Re: .htaccess resitrict a single file

    I agree ackerley1 .htaccess allows password protection at directory level and not for a certain file level.

    The one file is part of a cart system that steps through the same file 4 times (Product Select, Ship/Bill info, CC info, Order Confirm). I do not want the password to be triggered each step of the way just on the initial page request
    IMHO you will have to work on Cookies and sessions through programming.....( php JSP etc. )

Similar Threads

  1. dot htaccess file
    By caneman in forum Webmaster Resources Discussion Forum
    Replies: 3
    Last Post: 02-18-2010, 08:39 PM
  2. Single navigation file
    By thebloke in forum Google Discussion Forum
    Replies: 3
    Last Post: 03-09-2007, 06:07 PM
  3. help regarding .htaccess file
    By SES Trims in forum Search Engine Optimization Forum
    Replies: 1
    Last Post: 12-26-2006, 07:48 PM
  4. help regarding .htaccess file
    By SES Trims in forum Google Discussion Forum
    Replies: 3
    Last Post: 12-08-2006, 05:59 PM
  5. How to Call a .swf file on a single frame? (newbie)
    By msgoodie in forum Flash Discussion Forum
    Replies: 2
    Last Post: 11-26-2003, 02:43 PM

Posting Permissions

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