SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Addict
    Join Date
    Nov 2004
    Location
    St Petersburg, Russia
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    password-protected area using html file

    I understand pretty well how to protect php files with password using sessions (i.e. to create area which is only accessible after entering username and password). So I will need to replace html files that need to be protected with php files. But php files are usually more resource consuming.

    So maybe it is possible to protect html files by password without changing them to php? I.e. when user enters information, it is processed by php file, but after user enters password-protected area all files should be htmls. Is it possible?

  2. #2
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, it's possible, however it cannot be done with php only, you have to tune up your webserver as well. Assuming it's Apache, you can restrict access to the dir using http authorization (see apache mod_access docs), or use mod_rewrite to remap all "file.html" requests to something like "check_auth.php?file=file.html", where "check_auth.php" should check if the client is authorized to view given file.

  3. #3
    SitePoint Addict
    Join Date
    Nov 2004
    Location
    St Petersburg, Russia
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is it possible to use mod_rewrite if I dont actually have my own server, but use web hosting provider? And also will it be more efficient than just converting html files to php files? In other words is it worth while?

  4. #4
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should ask your hoster if they can install and configure mod_rewrite for you.

    As to efficiency, php is really fast, so if you don't expect more than 1000 hits per minute you won't see any difference between php and html.


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
  •