Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am looking at quickly password protecting a website, one folder on a server. I have played around with .htaccess and just realised that it's probably not working because it's likely it's sat on a windows server running PHP. I'am assumming this also means I can't use authenticate in PHP. Does any have any suggestions on a simple proctect I can implement in this scenario ? Thanks.

share|improve this question

migrated from stackoverflow.com Aug 18 '10 at 17:28

This question came from our site for professional and enthusiast programmers.

    
I meant .htaccess :) –  owen Aug 18 '10 at 13:23
    
What webserver software are you using? (IIS? Apache? Something else?) –  Rowland Shaw Aug 18 '10 at 13:24
    
Hi, I'm told it's IIS (I'm locked out from that) –  owen Aug 18 '10 at 13:28
    
check out SF: serverfault.com/questions/79034/… –  webbiedave Aug 18 '10 at 13:34
    
Thanks, think I may go down the route of building / using a PHP login script. –  owen Aug 18 '10 at 13:43
add comment

2 Answers

Basic access authentication is not OS-specific. It's part of the HTTP standard, but the implementation details are webserver specific. .htaccess is how the Apacheweb server implements this (and other features). If you can do other things (like URL rewriting) via .htaccess, then authentication should also work. If not, you have to find out what webserver you're using (probably IIS) and how to configure basic auth there.

share|improve this answer
    
Hmm, found out the hosting is with fasthosts - I can get into the panel but they charge for being able to configure basic auth. Is there anything I can do in PHP to achieve the same thing ? –  owen Aug 18 '10 at 13:35
add comment

If you're wanting to solve the problem in PHP solely, you could set a 'landing' page that requires a login or just password entry. Set up a cookie to store that information, then have each page check for the cookie. That's the way I would do it if I couldn't change the .htaccess file or wanted a PHP-only solution.

share|improve this answer
    
Cheers, that sounds like a plan. –  owen Aug 18 '10 at 13:45
2  
note that this doesn't protect access from non-HTML/PHP files in your folder. You might want to move such files to a folder outside the webroot and forward them via a PHP site protected as Saladin describes it. –  Anonymous Aug 18 '10 at 13:52
    
@nicolas78 Good point there. I didn't think of non-HTML/PHP content. –  Saladin Akara Aug 18 '10 at 14:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.