what goes first urlrewrite or context

Discussion in 'Install/Configuration' started by gdewey, Apr 2, 2013.

  1. gdewey

    gdewey Member

    when a request hits lswd what fires first the REWRITE RULES or a possible PROXY CONTEXT?

    I need a proxy context that hits

    www.domain.com/directory but TARGETS the proxy IP with out the directory name that was in the context URI.

    I assume that my rewrite rule should be something like:


    RewriteRule ^vanguardia/(.*)$ http://192.168.120.120/$1 [R=301,L]

    where my VH is
    http://192.168.120.120/vanguardia

    but needs to target the webserver destiny with out the directory

    any ideas on whats wrong?

    tks
  2. NiteWave

    NiteWave Administrator

    not very clear about your request.
    what does it mean ?
  3. gdewey

    gdewey Member

    ok let me put it in other way

    VH IP: 192.168.120.120
    Context /vanguardia/ (type proxy)

    WebServer external app: 50.22.195.205:80

    If I hit http://192.168.120.120/vanguardia

    it will proxy the request to: http://50.22.195.205:80/vanguardia

    my goal is to proxy the request EXCLUDING the context of the VH so it would just proxy to "http://50.22.195.205:80" with out the context directory.

    I am confuse on how the effect is on the rewriterule engine vs the target webserver.

    I've tried for hours using the P flag and many Regex.

    any ideas on how to acomplish?

    is there a variable for the ReWrite to match the target webserver? or is there a way to rewrite the target webserver external app?

    tks
  4. NiteWave

    NiteWave Administrator

    now almost clear, thanks for clarification.

    you can use rewriterule on virtual host(not .htaccess), and don't define any context. i.e., use virtual host level rewriterule to control all.

    as before, define a web server external app:
    name:test-proxy
    address:50.22.195.205:80

    the rewriterule in virtual host:
    RewriteRule /vanguardia/(.*) http://test-proxy/$1 [P]

    this should work as you expect.
  5. gdewey

    gdewey Member

    that very interesting :) the reason I was using the context is because I needed cache, but I assume I could also call the cache functionality using the same rewrite engine and that will overwrite the context right?

    so, correct me if I am right.. in order of importance there is

    SERVER
    VH
    CONTEXT
    REWRITE

    where from bottom to top it will overwrite one another.

    I am trying to use regex magic product to make some advance matches but it asks me for the type of regex engine.. rewrite module uses the perl flavor?, it has like 8 types :S

    I assume its the perl.
  6. NiteWave

    NiteWave Administrator

    not sure, but apache compatible, so look up apache document may get the answer.

    to enable cache:
    RewriteRule /vanguardia/(.*) http://test-proxy/$1 [P, E=Cache-Control:max-age=60]

    I recommend you focus on vhost rewriterule only in your case. don't use .htaccess and context for less confusion and better performance.

Share This Page