This is a discussion on mod_rewrite rule does not work within the Apache Web Server forums, part of the Web Server and Related Forums category; I have started using mod_rewrite through .htaccess but some of the RewriteRules will not work. My .htaccess is in the ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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: ------------------------------------------- IndexIgnore * RewriteEngine on RewriteRule ^insurancepolicy/?$ php/docs/Short-Term_Insurance_Policy_Summary.pdf RewriteRule ^sowing-resource-catalog/?$ php/docs/Sowing_Resource_Catalogue.pdf #THESE 2 RULES WORK FINE!! 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? I have tried all kinds of different ways of writing the regular expression, even tried putting them in an .htaccess file within the /php folder - but to no avail! HELP! Allan |
|
|||
|
"Frowning Freezer" <pub1@hverdag.dk> wrote in message
news:484e6450@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] and RewriteCond %{QUERY_STRING} http RewriteRule email\.php - [F] |
|
|||
|
>>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?? Allan |
|
|||
|
"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 |
| Thread Tools | |
| Display Modes | |
|
|