You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Martijn <us...@mindcontrolled.nl> on 2005/08/24 23:18:38 UTC

[users@httpd] Trouble with regexp on , using Apache 1.3.33

Hello everyone,

I've been trying to solve this for the last 2 days, but somehow I'm unable 
to see the logic here. Hope anyone can help me explain what's going on:

I've got a few directories, lets say they're named A, B, C and D.
Two of these (A and B) need to be restricted.

I figured that this should be done by the following regexp:
<Directory ~ "/home/websites/(A|B)">

To my knowledge, this should match /home/websites/A or /home/websites/B .
Instead, Apache matches everything in /home/websites and blocks access to C 
and D as well.

Strange, since a very similar regexp is shown in the apache 1.3 documentation:
http://httpd.apache.org/docs/1.3/mod/core.html#location

I also tried using (A|B)/? and several ways of matching the start and end 
of the string using ^ and $ , but to no effect.

In an attempt to isolate the problem, I tried something else:
<Directory ~ "(/home/websites/A|/home/websites/B)">
But strangely, this DOES match A but NOT B, so now I'm confused.
I've checked the path and I'm sure there are no mistakes there.

If I'm not using a regexp, eg. <Directory "/home/websites/A"> (or B), 
everything works like it should, so my guess would be that the contents of 
the directory-directive are right, only the regexp is the problem.

What am I missing here?

Thanks in advance,
Martijn. 


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Trouble with regexp on , using Apache 1.3.33

Posted by Martijn <us...@mindcontrolled.nl>.
Hello Joshua, thanks for your post.

That would be a valid solution if the real names where A and B, but 
unfortunately they're longer than a single character ("crewforum" and 
"stats" to be exact) and this wouldn't work on the virtual locations as well.

At 20:36 24-8-2005 -0400, you wrote:
>Well, I'm not sure why this doesn't work, but you shouldn't even need
>a regex for that.  You should be able to do
><Directory /home/websites/[AB]/>
>using shell-style wildcard character classes.  See:
>http://httpd.apache.org/docs/2.0/sections.html#file-and-web
>which is for a more modern version of the server but should still apply to 
>1.3.
>
> > I've got a few directories, lets say they're named A, B, C and D.
> > Two of these (A and B) need to be restricted.
> >
> > I figured that this should be done by the following regexp:
> > <Directory ~ "/home/websites/(A|B)">


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Trouble with regexp on , using Apache 1.3.33

Posted by Martijn <us...@mindcontrolled.nl>.
Hello Spike, thanks for your post.

That probably is a good approach, I could even symlink the second .htaccess 
to make sure both files are consistent.

Trouble is (and I forgot mention this in my first post, sorry about that), 
that I plan to use the same method (a regexp) for a few <Location> 
directives, where the locations are virtual (eg. server-status and 
throttle-status) and .htaccess can't be used.

Besides that, I'm also interested in why the regexp isn't working, just to 
know what went wrong.

Bottom line of my problem is I'm trying to make sure that every <Directory> 
(or virtual <Location>) is using the exact same list of restrictions.
I've tried solving this by doing something like

<Directory /foo>
include restrict.conf
</Directory>

where restrict.conf contains
---
order allow,deny
allow from foo
allow from bar
---
But Apache didn't like that.

Any other ideas to solve this are welcome as well.

Thanks,
Martijn.

At 14:20 24-8-2005 -0700, you wrote:
>Martijn,
>
>  Maybe I'm missing something, but in this case wouldn't using .htaccess 
> be a good approach?
>
>spike


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Trouble with regexp on , using Apache 1.3.33

Posted by Joshua Slive <js...@gmail.com>.
On 8/24/05, Martijn <us...@mindcontrolled.nl> wrote:
> Hello everyone,
> 
> I've been trying to solve this for the last 2 days, but somehow I'm unable
> to see the logic here. Hope anyone can help me explain what's going on:
> 
> I've got a few directories, lets say they're named A, B, C and D.
> Two of these (A and B) need to be restricted.
> 
> I figured that this should be done by the following regexp:
> <Directory ~ "/home/websites/(A|B)">

Well, I'm not sure why this doesn't work, but you shouldn't even need
a regex for that.  You should be able to do
<Directory /home/websites/[AB]/>
using shell-style wildcard character classes.  See:
http://httpd.apache.org/docs/2.0/sections.html#file-and-web
which is for a more modern version of the server but should still apply to 1.3.

Joshua.

> 
> To my knowledge, this should match /home/websites/A or /home/websites/B .
> Instead, Apache matches everything in /home/websites and blocks access to C
> and D as well.
> 
> Strange, since a very similar regexp is shown in the apache 1.3 documentation:
> http://httpd.apache.org/docs/1.3/mod/core.html#location
> 
> I also tried using (A|B)/? and several ways of matching the start and end
> of the string using ^ and $ , but to no effect.
> 
> In an attempt to isolate the problem, I tried something else:
> <Directory ~ "(/home/websites/A|/home/websites/B)">
> But strangely, this DOES match A but NOT B, so now I'm confused.
> I've checked the path and I'm sure there are no mistakes there.
> 
> If I'm not using a regexp, eg. <Directory "/home/websites/A"> (or B),
> everything works like it should, so my guess would be that the contents of
> the directory-directive are right, only the regexp is the problem.
> 
> What am I missing here?
> 
> Thanks in advance,
> Martijn.
> 
> 
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>   "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
> 
>

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Trouble with regexp on , using Apache 1.3.33

Posted by Spike Burkhardt <bu...@ssd.loral.com>.
Martijn,

  Maybe I'm missing something, but in this case wouldn't using .htaccess 
be a good approach?

spike

Martijn wrote:

> Hello everyone,
>
> I've been trying to solve this for the last 2 days, but somehow I'm 
> unable to see the logic here. Hope anyone can help me explain what's 
> going on:
>
> I've got a few directories, lets say they're named A, B, C and D.
> Two of these (A and B) need to be restricted.
>
> I figured that this should be done by the following regexp:
> <Directory ~ "/home/websites/(A|B)">
>
> To my knowledge, this should match /home/websites/A or /home/websites/B .
> Instead, Apache matches everything in /home/websites and blocks access 
> to C and D as well.
>
> Strange, since a very similar regexp is shown in the apache 1.3 
> documentation:
> http://httpd.apache.org/docs/1.3/mod/core.html#location
>
> I also tried using (A|B)/? and several ways of matching the start and 
> end of the string using ^ and $ , but to no effect.
>
> In an attempt to isolate the problem, I tried something else:
> <Directory ~ "(/home/websites/A|/home/websites/B)">
> But strangely, this DOES match A but NOT B, so now I'm confused.
> I've checked the path and I'm sure there are no mistakes there.
>
> If I'm not using a regexp, eg. <Directory "/home/websites/A"> (or B), 
> everything works like it should, so my guess would be that the 
> contents of the directory-directive are right, only the regexp is the 
> problem.
>
> What am I missing here?
>
> Thanks in advance,
> Martijn.
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server 
> Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>   "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>