LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 01-18-2017, 08:21 AM   #1
kjstecth
LQ Newbie
 
Registered: Jan 2017
Posts: 2

Rep: Reputation: Disabled
Apache: Location not allowed here


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
 
Old 01-19-2017, 12:33 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 12,840

Rep: Reputation: 1868Reputation: 1868Reputation: 1868Reputation: 1868Reputation: 1868Reputation: 1868Reputation: 1868Reputation: 1868Reputation: 1868Reputation: 1868Reputation: 1868
Hi and welcome to LQ,
Quote:
Originally Posted by kjstecth View Post
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

Regards
 
1 members found this post helpful.
Old 01-19-2017, 02:28 AM   #3
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 20 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2916Reputation: 2916Reputation: 2916Reputation: 2916Reputation: 2916Reputation: 2916Reputation: 2916Reputation: 2916Reputation: 2916Reputation: 2916Reputation: 2916
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.

<Limit> - http://httpd.apache.org/docs/current...ore.html#limit - on the other hand *can* be used in an .htaccess file.
 
Old 01-19-2017, 03:02 AM   #4
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 5,607
Blog Entries: 3

Rep: Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851
Quote:
Originally Posted by hydrurga View Post
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.
 
1 members found this post helpful.
Old 01-19-2017, 07:15 AM   #5
kjstecth
LQ Newbie
 
Registered: Jan 2017
Posts: 2

Original Poster
Rep: Reputation: Disabled
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

Its now working properly.
 
Old 01-19-2017, 08:04 AM   #6
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 5,607
Blog Entries: 3

Rep: Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851
Excellent.

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.
 
1 members found this post helpful.
Old 01-19-2017, 09:17 AM   #7
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Show us the code!
 
Old 01-19-2017, 09:23 AM   #8
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by kjstecth View Post
"[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"
This example appears to me to be missing a single right ">" on <Location

Code:
apache2ctl -D DUMP_VHOSTS
will show you the conf to examine for the suspected missing ">".

Reference: https://help.ubuntu.com/community/ApacheMySQLPHP
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Apache 2 error - symbolic link not allowed zedmelon Linux - Server 13 02-25-2019 08:06 AM
LXer: Google I/O Android News: Location, Location, Location (Plus Cloud Messaging and Bluetooth) LXer Syndicated Linux News 0 06-05-2013 01:00 PM
apache: location in location eantoranz Linux - Networking 2 08-08-2005 09:37 PM
Apache: Method Not Allowed Gerardoj Linux - General 2 03-21-2004 04:43 PM
Apache/Webdav/Dreamweaver MX MKCOL 405 Method not allowed swenz Linux - Software 0 03-31-2003 03:47 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration