Welcome to WebmasterWorld Guest from 54.167.22.37

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Unknown rewrite rule

     

leemon

7:20 pm on Sep 24, 2012 (gmt 0)

10+ Year Member



Hi!

Today I found a rewrite rule in the .htaccess file on one of my sites that I can't remember putting in there.


RewriteEngine on
RewriteCond %{QUERY_STRING} ^(%20|\+|\ )*(%2d|-)[^=]+$ [NC]
RewriteRule ^(.*) $1? [L]


My knowledge in Apache is not so great so any help in identifying what this rule does would be appreciated.

Thanks in advance

g1smd

7:48 pm on Sep 24, 2012 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



It apparently strips the query string if it begins with a space and then a hyphen and does not contain an equals sign.

It's coded as an internal rewrite, stripping those parameters before passing the query around inside the server.

The lack of a slash before the $1 leaves your server wide open to hacking by path injection.

Here's an object lesson in commenting your code so you know what it is supposed to do, months and years later. :)

leemon

7:56 pm on Sep 24, 2012 (gmt 0)

10+ Year Member



Thanks! My site got hacked a few months ago. Then, this is probably a remnant of that hack.

g1smd

8:07 pm on Sep 24, 2012 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



I'd say it was an attempt to protect against some sort of hack (except for someone accidentally leaving out the slash).
 

Featured Threads

Hot Threads This Week

Hot Threads This Month