View Single Post

  #4 (permalink)  
Old 06-10-2008
phantom
 
Posts: n/a
Default Re: mod_rewrite rule does not work

"Frowning Freezer" <pub1@hverdag.dk> wrote in message
news:484e6b3b@news.broadpark.no...
>>>I have started using mod_rewrite through .htaccess but some of the
>>>RewriteRules will not work. My .htaccess is in the root of the website
>>>and the content is:

>> <SNIP>
>>> RewriteRule story\.php.*http - [F]
>>> #this should block:
>>> http://www.domain.com/php/story.php?...mespamsite.com
>>> #BUT DOES NOT WORK :(
>>>
>>> RewriteRule email\.php.*http - [F]
>>> #this should block:
>>> http://www.domain.com/php/email.php?...mespamsite.com
>>> #BUT DOES NOT WORK :(
>>> -------------------------------------------
>>>
>>> Any ideas why the two last ones don't work?

>>
>> It doesn't work because the query string (the question mark and
>> everything after it) is not part of the URI you are trying to match, try
>> RewriteCond %{QUERY_STRING} http
>> RewriteRule story\.php - [F]

>
> Oh my, that's a bummer - had neither expected that or read that anywhere!
> Then I better understand why nothing worked. But is it then not possible
> to use data from the query string in the substitution string??
>

see here:
http://httpd.apache.org/docs/2.2/mod...ml#rewritecond
RewriteCond backreferences

as am example, if you have:
RewriteCond %{QUERY_STRING} ^(.*)$
then you can specify %1 in the rule substitution for the entire query string