Forum Moderators: phranque

Message Too Old, No Replies

THE_REQUEST to Deny .php

What am I missing?

         

jd01

10:00 pm on May 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Wondering if anybody can figure out what I am missing here:

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /[^.]\.php [NC]
RewriteRule . - [F]

No error, but .php files are not qualifying either.

Justin

Should add I have also tried:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /[^.]\.php.*\ /HTTP

jdMorgan

10:20 pm on May 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Probably this subpattern
/[^.]\.php
which matches a slash followed by a single character not equal to ".", followed by "php".

I suspect you intended somthing like
/[^.]+\.php
which matches slash followed by one or more characters not equal to ".", followed by "php".

If this isn't clear, check out the regular-expressions tutorial cited in our forum charter.

Jim

jd01

11:21 pm on May 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks Jim,

Knew it should be something simple I wasn't seeing (can only look at things for so long before I go cross-eyed), but even with the change and the very helpful tutorial... still no go.

I'll figure it out later, not critical. Might be something in the way I am trying to verify the match also.

I did try matching .php files in the rule, then using an un-opened/closed condition with $1, which if I am understanding correctly, should implicitly match 'anything' $1 'anything', so it's probably something silly in the verification on my end.

Justin

jdMorgan

9:08 pm on May 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



One other thing that I see -- now that my eyes are un-crossed -- is that the slash is on the wrong end of "HTTP".

It should be:


RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /[^.[b]]+\[/b].php.*\ [b]HTTP/[/b]

We're trying to match the request line from the browser, which would be something like:

GET /wodget.php HTTP/1.1

or
HEAD /subdir/widget.php?color=blue&texture=fuzzy HTTP/1.0

so that leading slash on "HTTP" in your pattern would have broken the match in RewriteCond.

Jim

jd01

11:03 pm on May 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thank you sir...

I hate the technicalities, especially when I don't enter them correctly.

Justin