|
|
|
|
||||||
| alt.apache.configuration Apache web server configuration issues. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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! |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
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. |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
"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 |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
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. |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
"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. |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
"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 |
|
![]() |
| Outils de la discussion | |
|
|