Jump to content

problems with htaccess password protection of file included in website wrapper


Guest kilbad

Recommended Posts

Guest kilbad
I have my index.php script shown below.  I have set it up so that I can call a file into the webpage wrapper based on a passed variable name.  However, I am having a problem.  Let's say I want to view the photos.php page in the wrapper.  I would have the URL http://www.example.com/index.php?id=photos (I will refer to this as URL1)  and this works fine.  If I wanted to view just the photos page without the wrapper my URL would be http://www.example.com/photos.php (we'll call this URL2) and this works fine.  However, now with regard to htaccess password protection of the photos.php file.. If I use the following code shown below, I get the user/pass popup box with URL2 but NOT URL1.  How do I get htaccess to protect the file in the case of URL1?

index.php::[code]
<?php

$id = $_GET['id'];


if ($id == "")

{
include 'header.php';
include 'frontpage.php';
include 'footer.php';
}

else

{
if (file_exists("$id.php")) {
 
include 'header.php';
include "$id.php";
include 'footer.php';

} else {

include 'header.php';
include 'error.php';
include 'footer.php';

}
}


?>
[/code]

.htaccess::[code]
<FilesMatch "(photos).php$">
AuthName "Restricted Area"
AuthType Basic
AuthUserFile /example/.htpasswd
AuthGroupFile /dev/null
require valid-user
</FilesMatch>
[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.