PDA

View Full Version : need a little help with redirection and expressions


ts77
03-24-2007, 04:22 AM
Hey folks,

I've moved some content from one subdomain to another which also changed the parameters a little bit.
So to avoid hitting the php-code I'd like to redirect in lsws directly but I'm having trouble with using the redirect context with expressions.

Essentially I have urls with
domain1.com/list.php?f=111
which changed to
domain2.com/list.php?111

I tried different expressions and none was successfull unfortunately. It seems to me as if I'm missing the obvious :(.

The current expression I'm trying is:
exp: ^/list.php?f=(.*)
with an external redirect and the target uri:
http://domain2.com/list.php?$1

whats wrong with that? I'm always still getting to the old php code on the page instead of getting redirected in lsws directly.
Oh, I'm on 2.2.6 with that machine btw.


thanks in advance,

thomas

mistwang
03-24-2007, 07:56 AM
You need to move this matching context up above the first non-matching context to give it higher priority.
The context configuration looks fine.

ts77
03-24-2007, 08:00 AM
hmm, strange. its actually the *only* context I have in that vhost :).

Any way to trace that? toggle debug didn't give me any output beside the admin-vhost.

mistwang
03-24-2007, 08:15 AM
I just realized There is a problem with your matching URI, it does not include query sting when matching the expression.

So, in this case, you have to use a Rewrite rule for this.

ts77
03-24-2007, 12:56 PM
ah, I knew I was missing the obvious ;).

but AFAIK rewrite engine also doesn't match on the query-string or am I wrong?


thanks,

thomas

mistwang
03-24-2007, 02:18 PM
That's true that rewrite rule only matches URI part, however, you can deal with query-string with a rewrite condition. :)

ts77
03-24-2007, 03:51 PM
to match it yeah but I don't get a part of the query string in a variable I guess ;).

Seems like I'm doomed to use some script engine to handle that sanely.


thanks,

thomas

mistwang
03-24-2007, 05:36 PM
You can use "%n" to back reference matched part from rewritecond in the final URL.

ts77
03-26-2007, 02:17 AM
works like a charm.
thanks a lot!


thomas