Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-16-2011, 04:10 PM   PM User | #1
efhx
New Coder

 
Join Date: Apr 2006
Posts: 64
Thanks: 0
Thanked 0 Times in 0 Posts
efhx is an unknown quantity at this point
Password Protecting site.com

I downloaded a file uploader to use on my website so I have my own personal file uploading service for my files so I dont have to worry about any being removed but I dont want it to be usable by the public which is why I would like to add a password to it.. I tried doing it with .htaccess and .htpasswd by using this:
Code:
AuthName "Restricted Area" 
AuthType Basic 
AuthUserFile /home/efhx/.htpasswd 
AuthGroupFile /dev/null 
<Files *.php>
require valid-user
</Files>
<Files *.js>
require valid-user
</Files>
for some reason, I can get it to work if it requires authentication for every single file/folder on the website but I cant get it to work with just php,js files.. so I'm looking for alternative ways. Is there anything I can do to make site.com password protected but the public would be able to view all my other folders like site.com/images ?
efhx is offline   Reply With Quote
Old 03-16-2011, 09:29 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,650
Thanks: 4
Thanked 2,451 Times in 2,420 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
This doesn't have anything to do with PHP, moving to apache configurations.

It doesn't look wrong, but I can't be 100% sure that the authtype works outside of the files block. Seems logical to me that it would. You can try this instead, and see how it works (I'm lazy, so I'll just use a filematch):
Code:
<FilesMatch "\.(php|js)$">
AuthName "Restricted Area" 
AuthType Basic 
AuthUserFile /home/efhx/.htpasswd 
Require valid-user
</FilesMatch>
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote
Old 03-17-2011, 01:16 AM   PM User | #3
efhx
New Coder

 
Join Date: Apr 2006
Posts: 64
Thanks: 0
Thanked 0 Times in 0 Posts
efhx is an unknown quantity at this point
finally figured it out.. there was a blank space after htpasswd and some of the other lines.. got rid of them and it worked thanks for the help
efhx is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:17 AM.


Advertisement
Log in to turn off these ads.