Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hello, found this on a google search. But like many different options I tried, I just cannot get this to work. Apache2.4.7-1ubuntu4.13 always writes in the error.log something like this "[Wed Jan 18 09:11:50.330171 2017] [core:alert] [pid 9049] [client 10.7.3.7:60354] /var/www/.htaccess: <Location not allowed here"
I tried different options like <limit> and now <location> but nothing every works. Its frustrating. I am putting an .htaccess file at the root of the webserver /var/www and I am trying to block the entire web directory structure from everyone except from 12 specific subnets.
Last edited by Mara; 01-18-2017 at 01:58 PM.
Reason: Moderator note: split from http://www.linuxquestions.org/questions/showthread.php?p=5656756#post5656756
Hello, found this on a google search. But like many different options I tried, I just cannot get this to work. Apache2.4.7-1ubuntu4.13 always writes in the error.log something like this "[Wed Jan 18 09:11:50.330171 2017] [core:alert] [pid 9049] [client 10.7.3.7:60354] /var/www/.htaccess: <Location not allowed here"
I tried different options like <limit> and now <location> but nothing every works. Its frustrating. I am putting an .htaccess file at the root of the webserver /var/www and I am trying to block the entire web directory structure from everyone except from 12 specific subnets.
Please note that <Location...> is not allowed inside a .htaccess file. You should put the <Location ...> ...</Location> snippet inside the apache config file.
You could also post your config here, so we could take a look in order to help you better
Backing up bathory's comments, can I add that if you're going to be playing about with Apache's directives, you should have the Apache documentation close to hand.
For example, regarding <Location>, the page http://httpd.apache.org/docs/current....html#location would have shown you straight away that <Location> is only valid in your server config file or virtual host definition, not in an .htaccess file. It would have saved you a lot of time.
on the other hand *can* be used in an .htaccess file.
Though if it is your own server, you should not be using .htaccess files. Instead the right place for the configuration changes is in the configuration files themselves. That keeps them in a single place and makes them easier to manage, among other things. Easier means fewer mistakes and less wasted time / money.
Ok so what happened was that in my google searches and reading things from stack exchange and ubuntu forums, and other places of the web... They were all talking about .htaccess files in the conversation. I initially tried the limit directive inside an .htaccess file but ended up with the same problem. For whatever reason a lot of topics kept mentioning .htaccess so my mind was driven on that as the way to accomplish this. But you are all right... take a step back, don't believe everything you read on the internet... The correct way that I ended up accomplishing this was to place this code in the following file: /etc/apache2/conf.d/restrict.conf
The .htaccess references cause a lot of trouble yet persist for reasons that I can't really do more than speculate on. The Include directive seems to have been added in Apache 1.3 : http://httpd.apache.org/docs/1.3/mod/core.html#include So any reference to desiring .htaccess pre-dates the year 1998 It'd save a lot of wasted effort to be able to mark those old notes as deprecated.
Back then shared hosting was still in vogue and often necessary. So shared hosting could be the cause of promoting .htaccess However even back then sudo still existed. Between a properly configured sudo and use of the Include directive, even back then, there should be no need for .htaccess. But I guess that is something for historians to look into before the key people all kick off or just plain forget.
Anyway, you've gotten it working. Hopefully this thread or one like it will turn up when people have a similar configuration question in the future.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.