redirect for urls questions

Post Reply
gerry.odea
Posts: 98
Joined: Fri Sep 19, 2008 9:33 am

redirect for urls questions

Post 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.
User avatar
mark
Site Admin
Posts: 5513
Joined: Tue Apr 25, 2000 6:56 pm

redirect for urls questions

Post 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".
User avatar
mark
Site Admin
Posts: 5513
Joined: Tue Apr 25, 2000 6:56 pm

redirect for urls questions

Post 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>
User avatar
Kai
Site Admin
Posts: 1271
Joined: Tue Apr 25, 2000 1:27 pm

redirect for urls questions

Post 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).)
gerry.odea
Posts: 98
Joined: Fri Sep 19, 2008 9:33 am

redirect for urls questions

Post 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>
User avatar
mark
Site Admin
Posts: 5513
Joined: Tue Apr 25, 2000 6:56 pm

redirect for urls questions

Post 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>
Post Reply