0
   

Restricting Access via .htaccess

 
 
Reply Tue 5 Dec, 2006 09:34 pm
I have a bunch of machines behind a firewall that act as my internal network (all running Linux). I am trying to setup a website (LAMP environment) that is only accessible for those internal machines. That is, they should only be able to access the webpage if their IP address matches my list.

I set the following in my httpd.conf file (so the .htaccess files can override the httpd.conf settings):
Code:
<Directory>
AllowOverride All
</Directory>

AccessFileName .htaccess
DefaultType text/plain


then restarted my apache server.

I then created an .htaccess file in the directory I wish to restrict access with the following:
Code:
order deny,allow
deny from all
allow from xxx.xxx.xxx.xxx

where "xxx.xxx.xxx.xxx" is the IP address I wish to allow access.

The above works as intended for those IP addresses not allowed (i.e. it returns an "Access Forbidden" code). However, for the allowed IP address, it treats the index.html file as an unrecognised mime type (it thinks it is an "text/x-server-parsed-html" mime type and asks me to download it instead of showing the page.

Also note that my httpd.conf file has the following:
Code:
<IfModule>
DirectoryIndex index.html index.htm
<IfModule>

So, it should return the index.html page when the URL is pointed to its directory. It returns it just fine for any directory that does not have an .htaccess file. Although, I am wondering if the "mod_dir.c" should be changed to "dir_module" as it is loaded that way (i.e. "LoadModule dir_module modules/mod_dir.so").

So, I tried to force it to recognise the mime type by adding the following to the .htaccess file:
Code:
AddType text/x-server-parsed-html .html
ForceType text/html .html


and various other versions of the above. Still doesn't work. The mime types are all declared (as they should be) in the mime.types file (in the "conf" directory). Nothing else was changed in the httpd.conf file.

I have done some Google searches, etc. This is a rather odd problem. I have been able to do what I am trying to do here on my localhost and there are no problems with the mime types. I have never even heard of a restricted access affecting mime types.

Any ideas?
  • Topic Stats
  • Top Replies
  • Link to this Topic
Type: Discussion • Score: 0 • Views: 734 • Replies: 3
No top replies

 
cicerone imposter
 
  1  
Reply Wed 6 Dec, 2006 01:49 pm
Christoph, First of all, welcome to a2k. You need to seek out timber, our a2k expert, to get computer related answers.
0 Replies
 
parados
 
  1  
Reply Wed 6 Dec, 2006 03:21 pm
This sounds like more of a Jesaph or Craven question.

You don't have the issue without an .htaccess file so
do you have the issue with an .htaccess file that does nothing?

A2K is a great place but it may take a while to get an answer to your very technical linux question.

There are a couple of forums online dedicated to just linux questions. They tend to be more responsive and often you can find the answers by searching them. One I tend to use is linuxquestions.org. Others are linuxhelp.net and linuxforums.org.
0 Replies
 
Christoph
 
  2  
Reply Wed 6 Dec, 2006 06:01 pm
Thanks for the replies. I am actually not new to a2k; Craven de Kere is a personal friend of mine. I have been posting this question on many forums, as it is really something I haven't seen before. I know the LAMP environment pretty well and I am stumped.

Thanks again!
0 Replies
 
 

Related Topics

Clone of Micosoft Office - Question by Advocate
Do You Turn Off Your Computer at Night? - Discussion by Phoenix32890
The "Death" of the Computer Mouse - Discussion by Phoenix32890
Windows 10... - Discussion by Region Philbis
Surface Pro 3: What do you think? - Question by neologist
Windows 8 tips thread - Discussion by Wilso
GOOGLE CHROME - Question by Setanta
.Net and Firefox... - Discussion by gungasnake
Hacking a computer and remote access - Discussion by trying2learn
 
  1. Forums
  2. » Restricting Access via .htaccess
Copyright © 2024 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.27 seconds on 11/20/2024 at 05:22:00