NetTalk Central

NetTalk Web Server => Web Server - Ask For Help => Topic started by: Niels Larsen on July 08, 2019, 04:09:46 AM

Title: friendly url - how to?
Post by: Niels Larsen on July 08, 2019, 04:09:46 AM
Hi

I think I've read about it somewhere in the documentation a long time ago. But I simply can't remember where?
Can anyone help?

Regards Niels
Title: Re: friendly url - how to?
Post by: Bruce on July 09, 2019, 02:30:36 AM
In WebHandler, ReadFile method, AFTER parent call.
Check the Return value there, and if it's 404 (page not found) then "rewrite" the p_FileName variable.

For example, I have a table "Quicklinks". So my code looks like this;

  If returnValue = 404 ! page not found, so check quicklinks file to see if there's a match
    Access:quickLinks.Open()
    Access:quickLinks.UseFile()
    Qui:Quick = sub(p_FileName,len(clip(self.site.WebFolderPath) & '\')+1,255)
    If Access:QuickLinks.Fetch(Qui:QuickKey) = 0
      Qui:full = clip(self.site.WebFolderPath) & '\' & Qui:Full
      ReturnValue = PARENT.ReadFile(Qui:Full,p_Buffer,p_FileDate,p_FileTime,p_Parse,pShared)
    end 
    Access:quickLinks.Close()
  End

Cheers
Bruce
Title: Re: friendly url - how to?
Post by: Niels Larsen on July 09, 2019, 09:15:40 PM
Thanks Bruce

I'll try it.
Am I wrong when I remember reading about it in the documentation - a long time ago?

Title: Re: friendly url - how to?
Post by: Bruce on July 09, 2019, 09:47:46 PM
probably - I don't remember documenting this, although I may have gone over it in training or a webinar or something.

cheers
Bruce
Title: Re: friendly url - how to?
Post by: Alberto on July 10, 2019, 07:28:43 AM




 



  If returnValue = 404 ! page not found, so check quicklinks file to see if there's a match
    Access:quickLinks.Open()
    Access:quickLinks.UseFile()
    Qui:Quick = sub(p_FileName,len(clip(self.site.WebFolderPath) & '\')+1,255)
    If Access:QuickLinks.Fetch(Qui:QuickKey) = 0
      Qui:full = clip(self.site.WebFolderPath) & '\' & Qui:Full
      ReturnValue = PARENT.ReadFile(Qui:Full,p_Buffer,p_FileDate,p_FileTime,p_Parse,pShared)
    end 
    Access:quickLinks.Close()
  End

I dont understandt wht is it code for... please explain, thanks
Title: Re: friendly url - how to?
Post by: Bruce on July 10, 2019, 11:33:58 PM
It allows you to map a "friendly" URL to some "real" URL.

Cheers
Bruce