Page 1 of 1

redirect for urls questions

Posted: Mon Nov 02, 2015 7:29 am
by gerry.odea
I'm using this to redirect url queries to the actual site.
rex "[^.]+>>=" $q><if $ret like "(ac,ae,at,au,be,biz,br,by,bz,ca,cc,ch,cl,cn,com,cz,de,dk,ec,edu,eg,eu,es,fr,ge,gov,gr,hu,id,ie,il,info,in,ir,it,jp,ke,kr,kz,la,link,lt,mk,ml,mx,net,nu,nz,org,pl,pro,pt,ru,science,se,su,th,tk,tr,tv,tw,uk,ua,us,ve,vn,ws,za,zw)"><strfmt "http://%s" $q><header name=location value="$ret"></if></a>

but for some reason the .in and .id don't redirect and I just noticed that if I type somesite,net it detects the comma as a period.

Can you please let me know what I'm doing wrong, I would really appreciate it. Thanks.

redirect for urls questions

Posted: Mon Nov 02, 2015 7:52 am
by mark
"in" is a noise word "id" and "net" work for me with your code.

Use <apicp keepnoise 1> to not strip the "in".

redirect for urls questions

Posted: Mon Nov 02, 2015 7:58 am
by mark
For the "abc,net" in metamorph , separates terms so your query of
"'abc,net' like 'net'" matches.

Maybe just use rex to match the whole thing:
<rex "[\alnum\-.]+.=[\alpha]{2,10}>>=" $q><$hostname=$ret>
<if $hostname ne ''><!-- issue redirect --></if>

redirect for urls questions

Posted: Mon Nov 02, 2015 10:16 am
by Kai
With Texis 6+ you can avoid Metamorph syntax and noise issues by using IS SUBSET OF:

<rex "[^.]+>>=" $q>
<if lower($ret) is subset of ( "ac", "ae", "in", "etc" )>
true
</if>

Note that you'll need spaces before each open quote or Vortex will complain. (And each literal domain should be lowercase, to match the lower($ret).)

redirect for urls questions

Posted: Mon Nov 02, 2015 11:08 am
by gerry.odea
<rex "[\alnum\-.]+.=[\alpha]{2,10}>>=" $q><$hostname=$ret>
<if $hostname ne ''><!-- issue redirect --></if>

can you please break this down for me? So that I understand what it is doing? Thanks BTW, It seems to be working but I'm doing it like this:

<if $q like "(.ae,.cc,.au,.be,.biz,.br,.bz,.ca,.ch,.cl,.cn,.com,.cz,.de,.dk,.edu,.eg,.eu,.es,.fr,.ge,.gov,.gr,.hu,.id,.ie,.il,.in,.info,.ir,.it,.jp,.ke,.kr,.la,.link,.lt,.ml,.net,.nu,.nz,.org,.pl,.pro,.pt,.ru,.science,.se,.su,.th,.tk,.tr,.tv,.tw,.uk,.ua,.us,.ve,.vn,.ws,.za,.zw)"><rex "[\alnum\-.]+.=[\alpha]{2,10}>>=" $q><$hostname=$ret><if $hostname ne ''><strfmt "http://%s" $q><header name=location value="$ret"></if></if>

redirect for urls questions

Posted: Mon Nov 02, 2015 12:21 pm
by mark
My suggestion is not to the like at all, just the rex. The anchor, >>=, on the end makes it match right-to-left. So starting at the end look backwards for 2-10 letters, then a . (oops, that should be \. for the literal dot), then 1 or more valid hostname characters.

<rex "[\alnum\-.]+\.=[\alpha]{2,10}>>=" $q>
<$hostname=$ret>
<if $hostname ne ''><!-- $q smells like a hostname, issue redirect -->
<strfmt "http://%s" $q>
<header name=location value="$ret">
<exit>
</if>