PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > alt.apache.configuration > mod_security2 - ReWrite URL, bypassing Location ReWrites?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
alt.apache.configuration Apache web server configuration issues.

mod_security2 - ReWrite URL, bypassing Location ReWrites?

Réponse
 
LinkBack Outils de la discussion
Vieux 25/01/2008, 11h27   #1
boole
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut mod_security2 - ReWrite URL, bypassing Location ReWrites?

I want to rewrite a request from a matched REMOTE_ADDR (IP Address),
but I can only find in the mod security reference how to give a
status, which would return my custom error page, but I would like the
client to recieve a 200 status and be re-written to an internal URL,
is this possible?

Also, if you fancy ing even more, I am doing security level
rewrites, but the web app itself has rewrite rules in .htaccess, so
when I try

(mod_rewrite)
RewriteCond %{REMOTE_ADDR}
RewriteRule !^rewrite_dest\.htm$ [L]

It also goes through the .htaccess rewrites... I thought [L] meant
stop processing rules, unless the .htaccess counts as another
rewriteengine instance, I think i've answered my own question? Can
anyone me get around this? I just want to say, if this IP match,
rewrite to this internal site URL, finish, nothing else, stop, do the
rewrite, no more rewrites, no more incarnations of mod_rewrite, no
nothing, just serve that url please.

If either mod_security or mod_rewrite can do this please let me know.

Thank you very much apache pro's!
  Réponse avec citation
Vieux 25/01/2008, 11h32   #2
boole
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: mod_security2 - ReWrite URL, bypassing Location ReWrites?

On 25 Jan, 11:27, boole <geo...@gmail.com> wrote:
> I want to rewrite a request from a matched REMOTE_ADDR (IP Address),
> but I can only find in the mod security reference how to give a
> status, which would return my custom error page, but I would like the
> client to recieve a 200 status and be re-written to an internal URL,
> is this possible?
>
> Also, if you fancy ing even more, I am doing security level
> rewrites, but the web app itself has rewrite rules in .htaccess, so
> when I try
>
> (mod_rewrite)
> RewriteCond %{REMOTE_ADDR}
> RewriteRule !^rewrite_dest\.htm$ [L]
>

Oh, and I tried [L,S=10] to skip the following rewrites, but they are
still processed.
  Réponse avec citation
Vieux 25/01/2008, 13h15   #3
HansH
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: mod_security2 - ReWrite URL, bypassing Location ReWrites?

"boole" <geocoo@gmail.com> schreef in bericht
news:86e5abf9-6b42-4b2b-9690-ac9d5c4c5ac0@l32g2000hse.googlegroups.com...
>I want to rewrite a request from a matched REMOTE_ADDR (IP Address),
> but I can only find in the mod security reference how to give a
> status, which would return my custom error page, but I would like the
> client to recieve a 200 status and be re-written to an internal URL,
> is this possible?
>
> Also, if you fancy ing even more, I am doing security level
> rewrites, but the web app itself has rewrite rules in .htaccess, so
> when I try
>
> (mod_rewrite)
> RewriteCond %{REMOTE_ADDR}
> RewriteRule !^rewrite_dest\.htm$ [L]

No substitution specifeid in rule
If this is not in a .htaccess a / is missing in the url to match.
If this is in server config while you use vhost, move it to the vhost.
You may have to start the rewriteengine per container
Unsure why you use an not-match ...

Try
RewriteEngine ON
RewriteCond %{REMOTE_ADDR} 1.2.3.4
RewriteRule . /rewrite_dest\.htm [L]

HansH


  Réponse avec citation
Vieux 25/01/2008, 14h24   #4
boole
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: mod_security2 - ReWrite URL, bypassing Location ReWrites?

On 25 Jan, 13:15, "HansH" <ha...@invalid.invalid> wrote:
> "boole" <geo...@gmail.com> schreef in berichtnews:86e5abf9-6b42-4b2b-9690-ac9d5c4c5ac0@l32g2000hse.googlegroups.com...>I want to rewrite a request from a matched REMOTE_ADDR (IP Address),
> > but I can only find in the mod security reference how to give a
> > status, which would return my custom error page, but I would like the
> > client to recieve a 200 status and be re-written to an internal URL,
> > is this possible?

>
> > Also, if you fancy ing even more, I am doing security level
> > rewrites, but the web app itself has rewrite rules in .htaccess, so
> > when I try

>
> > (mod_rewrite)
> > RewriteCond %{REMOTE_ADDR}
> > RewriteRule !^rewrite_dest\.htm$ [L]

>
> No substitution specifeid in rule
> If this is not in a .htaccess a / is missing in the url to match.
> If this is in server config while you use vhost, move it to the vhost.


Sorry Hans I wrote this quickly this morning, I should make sure I use
correction citations in future, in the ACTUAL VirtualHost config file,
I do include a substitution, and a leading '/'.

> You may have to start the rewriteengine per container
> Unsure why you use an not-match ...


I am trying to do this:
If the request IP_ADDR matches a given criterea, make sure that client
only ever recevies a certain page whatever they request.
From small experience with rewrites, I have learnt that if you want
only one page to be given whatever the request is, you need to use a
negative match to exlude the rewritted url from being infinatley
rewritten and causing a 500 response code.

I think I would also need to do the same for every image, css etc
which is used in the page, hence meaning a subdirectory would be good
to match against, that isnt a problem, the problem is the fact that I
cant find a way to explicitly rewrite to a URl without processing
further contained rewrites.

>
> Try
> RewriteEngine ON
> RewriteCond %{REMOTE_ADDR} 1.2.3.4
> RewriteRule . /rewrite_dest\.htm [L]
>
> HansH


This would only work for one character matches... which is not the
case in this request(s), it needs to match anything BUT the page I am
rewriting the client to.

Any would be appreciated.
  Réponse avec citation
Vieux 25/01/2008, 14h44   #5
phantom
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: mod_security2 - ReWrite URL, bypassing Location ReWrites?

"boole" <geocoo@gmail.com> wrote in message
news:103cd681-a695-4b22-bc85-33b92f57ba97@v17g2000hsa.googlegroups.com...
>
> I am trying to do this:
> If the request IP_ADDR matches a given criterea, make sure that client
> only ever recevies a certain page whatever they request.
> From small experience with rewrites, I have learnt that if you want
> only one page to be given whatever the request is, you need to use a
> negative match to exlude the rewritted url from being infinatley
> rewritten and causing a 500 response code.
>
> I think I would also need to do the same for every image, css etc
> which is used in the page, hence meaning a subdirectory would be good
> to match against, that isnt a problem, the problem is the fact that I
> cant find a way to explicitly rewrite to a URl without processing
> further contained rewrites.
>
>>
>> Try
>> RewriteEngine ON
>> RewriteCond %{REMOTE_ADDR} 1.2.3.4
>> RewriteRule . /rewrite_dest\.htm [L]
>>
>> HansH

>
> This would only work for one character matches... which is not the
> case in this request(s), it needs to match anything BUT the page I am
> rewriting the client to.


No, it would work for at least one character matches - the regex only has to
match part of the URI unless you explicitly use the start and end of string
characters - ^$
The [L] *should* prevent the rewritten request from being matched again.


  Réponse avec citation
Vieux 25/01/2008, 17h09   #6
HansH
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: mod_security2 - ReWrite URL, bypassing Location ReWrites?

"boole" <geocoo@gmail.com> schreef in bericht
news:103cd681-a695-4b22-bc85-33b92f57ba97@v17g2000hsa.googlegroups.com...
> On 25 Jan, 13:15, "HansH" <ha...@invalid.invalid> wrote:
>> "boole" <geo...@gmail.com> schreef in
>> berichtnews:86e5abf9-6b42-4b2b-9690-ac9d5c4c5ac0@l32g2000hse.googlegroups.com...>I
>> want to rewrite a request from a matched REMOTE_ADDR (IP Address),

> I am trying to do this:
> If the request IP_ADDR matches a given criterea, make sure that client
> only ever recevies a certain page whatever they request.
> From small experience with rewrites, I have learnt that if you want
> only one page to be given whatever the request is, you need to use a
> negative match to exlude the rewritted url from being infinatley
> rewritten and causing a 500 response code.

That applies mostly to external rewrites aka redirects: the browser will
then make a new request

It may apply to internal _subrequests_ introduced by other sever components
eg mod_include too, adding the NS-flag seems an easy cure:
RewriteRule . /rewrite_dest\.htm [L,NS]
http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html

> I think I would also need to do the same for every image, css etc
> which is used in the page, hence meaning a subdirectory would be good
> to match against, that isnt a problem, the problem is the fact that I
> cant find a way to explicitly rewrite to a URl without processing
> further contained rewrites.
>>
>> Try
>> RewriteEngine ON
>> RewriteCond %{REMOTE_ADDR} 1.2.3.4
>> RewriteRule . /rewrite_dest\.htm [L]

>
> This would only work for one character matches...

A single-character-only match requires a pattern of ^.$
Without begin and end markers it just matches any character anywhere.

How about

RewriteEngine ON
RewriteMap address txt:/path/to/file/lockedips
RewriteCond %{REQUEST_URI} !^/lockeddown
RewriteRule (.*) ${adress:%{REMOTE_ADDR}|$1} [L]

and listing offencive IPs in /path/to/file/lockedips like
1.2.3.4 /lockeddown/


HansH


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 20h42.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,17299 seconds with 14 queries