The Un-Official Proxomitron Forum

Full Version: Redirecting URLs using variables
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm having trouble getting URLs to redirect when using replacement variables.
For example, on Youtube's user channel pages the default is to show only "featured" videos. Instead, I'd rather it redirect to the URL showing all videos (that you get by clicking "browse videos")

Sample URLs: The first URL is the default, the second shows all vids

http://www.youtube.com/user/0zMovies
http://www.youtube.com/user/0zMovies/videos?view=0

It redirects if you use a channel name:
Code:
www.youtube.com/user/0zMovies     $RDIR(http://www.youtube.com/user/0zMovies/videos?view=0)

But doesn't with a variable:
Code:
www.youtube.com/user/\1     $RDIR(http://www.youtube.com/user/\1/videos?view=0)
Depending on where the code is, you may have to make the Proxomitron keep looking and fill the variable.

With

Code:
www.youtube.com/user/\1   $RDIR(http://www.youtube.com/user/\1/videos?view=0)

the Proxomitron may find "www.youtube.com/user/", realize the match, and stop looking.

Try something like

Code:
www.youtube.com/user/\1  &   $RDIR(http://www.youtube.com/user/\1/videos?view=0)

or

Code:
www.youtube.com/user/(?+)\1   $RDIR(http://www.youtube.com/user/\1/videos?view=0)

HTH
Both of those work when the user name is at the end of the URL, like in my example.
But I've found they do not redirect when the links to the user page have additional text on the end such as:
http://www.youtube.com/user/mesmerlotus?feature=watch
But I got it to work by adding a 2nd redirect:
Code:
www.youtube.com/user/\1\?feature=watch      $RDIR(http://www.youtube.com/user/\1/videos?view=0)
I suppose I could keep adding them for each new link style.

Several things I don't understand:
Why does the AND symbol separated by spaces cause the text after "user/" to be matched?

Why would filling the variable be in question at all? I thought it would only be triggered if text existed after "user/". If the text is there, how can it not be seen?
Since this goes in the Exceptions-U list, I'm confused about why you mentioned "Depending on where the code is." Lists don't search through html & css like a filter, do they? I thought it would only catch the URL if it were actually requested.
(Feb. 15, 2013 05:37 PM)zoltan Wrote: [ -> ]I suppose I could keep adding them for each new link style.

Or maybe

Code:
www.youtube.com/user/([^?]+)\1      $RDIR(http://www.youtube.com/user/\1/videos?view=0)

?

(Feb. 15, 2013 05:37 PM)zoltan Wrote: [ -> ]Several things I don't understand:
Why does the AND symbol separated by spaces cause the text after "user/" to be matched?

Why would filling the variable be in question at all? I thought it would only be triggered if text existed after "user/". If the text is there, how can it not be seen?

Since this goes in the Exceptions-U list, I'm confused about why you mentioned "Depending on where the code is." Lists don't search through html & css like a filter, do they? I thought it would only catch the URL if it were actually requested.

It is as Scott Lemmon wanted or left it. The spaces are not needed, btw.

A trailing \1 used in the matching expression of a web page filter captures code. A trailing \1 in a URL match or list entry, called from a URL match, does not.

Exceptions-U is called by the URL match of a header filter. It can catch requested URLs. It does not filter html.

Lists called by the matching expressions of web page filters can search through html, css, etc.

HTH

Edit: added , called from a URL match,
Thanks. That works perfectly.

I'm assuming the "([^?]+)\1" means look for a run of any character that's not a question mark and place it into the variable?

On the other hand, why doesn't it interpret the "?" as the Prox meta character meaning "any character" -- which would seem to prevent it from capturing anything into the variable.

Quote:It is as Scott Lemmon wanted or left it. The spaces are not needed, btw.
OK. It's just not evident to me what the "&" symbol's meaning/function is here. The description of it on the matching language page doesn't seem to cover an instance like this.

Quote:A trailing \1 used in the matching expression of a web page filter captures code. A trailing \1 in a URL match or list entry does not.
Very important to know. I never realized this. So, at least something in parentheses will always be necessary to signal that something should go into the variable (for URLs and lists)?
(Feb. 17, 2013 06:31 AM)zoltan Wrote: [ -> ]I'm assuming the "([^?]+)\1" means look for a run of any character that's not a question mark and place it into the variable?

Correct.

(Feb. 17, 2013 06:31 AM)zoltan Wrote: [ -> ]On the other hand, why doesn't it interpret the "?" as the Prox meta character meaning "any character" -- which would seem to prevent it from capturing anything into the variable.

I think \ and ^ are the only special characters that are not escaped when inside []. So you could try [^\?]+, if it helps.

(Feb. 17, 2013 06:31 AM)zoltan Wrote: [ -> ]
Quote:It is as Scott Lemmon wanted or left it. The spaces are not needed, btw.
OK. It's just not evident to me what the "&" symbol's meaning/function is here. The description of it on the matching language page doesn't seem to cover an instance like this.

It really is about Scott's choices and the time he had to spare. I'll guess:
The & indicates that the matching has not been completed. If there is a \1 in front of the &, there is a good chance that the data available to \1 will be needed later on. So "\1&" causes \1 to fill. Of course, what follows the & doesn't actually have to match code; it has to be "true". This "choice" also keeps us from typing (?+)\1.

(Feb. 17, 2013 06:31 AM)zoltan Wrote: [ -> ]
Quote:A trailing \1 used in the matching expression of a web page filter captures code. A trailing \1 in a URL match or list entry does not.
Very important to know. I never realized this. So, at least something in parentheses will always be necessary to signal that something should go into the variable (for URLs and lists)?

IIRC, where the expression is used is the deciding factor. A trailing \1 in the filter's URL Match field or in a list that is called from the URL Match field needs help. I think, the same for the "Bypass any URLs that match this expression" field.

HTH
Thanks for all the info. I think I'll start adding some of things I've learned here to my permanent help file. It's well put together as is, but some things aren't covered - not to mention that I sometimes need an extended "for dummies" explanation.
(Feb. 18, 2013 04:26 AM)zoltan Wrote: [ -> ]I think I'll start adding some of things I've learned here to my permanent help file.

Run some tests before carving my words in stone. Wink

Have fun
Reference URL's