Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.htaccess protect entire site, apart from 3 files. 1

Status
Not open for further replies.

BlankCanvas

Technical User
Nov 12, 2002
5
TH
Hi, Can anyone tell me if it is possble to protect an entire site using .htaccess files whilst still allowing 3 files to be accessed by any user. i.e. splash.html, splash.jpg & banner.jpg .

My current .htaccess looks like this:

#Start of File.
DirectoryIndex splash.html
AuthType Basic
AuthName "Beta Site"
AuthUserFile /sites/site1/users.htpasswd
require valid-user
#End of File.

What i need is to allow the first page to display along with a logo, giving the users some basic information.

Thanks

Stephen
 
Hi,

Why not using 2 folders instead. First folder contain these three files and within html create a link to point to other page (folder 2) that require authentication.

regards,
feroz
 
Hi dbase77,

Agree with what you are saying and already thinking of doing something along those lines. However I have severl sites, with existing pages and external links that would be a nightmare to update in one go.

It may not be possible at all, but if I can great. a one file solution for my problem :)

Thanks

Stephen
 
Hi,

I dont think so you can do that. Not from my experience. But if you require to edit many files just to insert 1 line, I can you can achieve this within linux/unix environment.

regards,
feroz
 
You could make use of the [tt]<FilesMatch>[/tt] directive. It would be a pain to create, but would allow you to do what you want.
Something like
[tt]<FilesMatch &quot;^([^a][^b][^c][^\.][^d][^e][^f]|[^g][^h][^i][^j][^\.][^k][^l])$&quot;>
Require valid-user
</FilesMatch>[/tt]
This would require a valid authentication, unless the filename is [tt]abc.def[/tt] or [tt]ghij.kl[/tt]. //Daniel
 
Depending on your set-up and how many files you are wanting to protect overall, you could move the files to a new directory and then use redirect rules so that any call to the old file is redirected to the protected directory, this saves you altering all the sites links to point to a new directory.

Daniel

You get a star from me. I have a problem totally unrelated to the one in this thread and your post just made me think of a possible solution. Thanks.

Hope this helps Wullie


The pessimist complains about the wind. The optimist expects it to change.
The leader adjusts the sails. - John Maxwell
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top