Jump to content

using PHP to bypass .htaccess ?


rogerios

Recommended Posts

Hi.

I have chosen to protect my website using .htaccess since I use a LeftFrame for navigation, and a MainFrame to load PDF Documents.

Now, I have three different sites, and, I need a 'User Manager' interface which allows the admin to control user access to any combination of these sites. I have actually used a global PHP login, which provides respective access to a PHP file with this line only:

header("Location: [a href=\"http://username:password@website_X");\" target=\"_blank\"]http://username:password@website_X");[/a]
* That would forward the user and somewhat secretly bypass the browser's request for a new password. Since IE now prohibits passwords within URLs by default, this can no longer be achieved...

The question is, how can I protect those PDF documents and authenticate via PHP, using a MySQL database to keep track of user details?

Does $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW'] have anything to do with .htaccess? Could this be an alternative?

Thank you :)

Roger
Link to comment
Share on other sites

To answer my own question (after more research).

This can be achieved with these lines:

<?php
$pdf = 'dummy.pdf';
header('Content-type: application/pdf');
//header('Content-Disposition: attachment; filename="'.$pdf.'"');
readfile($pdf);
?>

...just in case anyone else is searching on this topic :)
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.