NetTalk Central

NetTalk Web Server => Web Server - Ask For Help => Topic started by: Stu on December 07, 2016, 02:52:24 PM

Title: How to do a 301 Redirect from "www" to "root"?
Post by: Stu on December 07, 2016, 02:52:24 PM
Hi Bruce/Folks,

Specific question (arising out of another post below).

What's the best way to do a 301 Redirect for "www" urls pushing them to the "root" (non-www) urls?

(https://support.google.com/webmasters/answer/93633)

I've gone through the webhandler embeds that I do use for redirecting and doing lots of magic stuff. But am not sure of the right place to be able to adjust the "www".

Cheers.
Title: Re: How to do a 301 Redirect from "www" to "root"?
Post by: Bruce on December 12, 2016, 02:12:14 AM
so the call is

p_web.Redirect(toURL)

I think the best place for it is in WebHandler, _SendFile, after loc:filename is set...
something along the lines of

  if lower(sub(loc:filename,1,3)) = 'www'
    self.redirect....
    return
  end


cheers
Bruce
Title: Re: How to do a 301 Redirect from "www" to "root"?
Post by: Stu on December 13, 2016, 01:46:53 PM
Thanks Bruce, really appreciate this.

What's cool is that the solving of the relative urls issue (other thread) meant this no longer was something that needed to happen. Thankfully.

But is a great piece of info/how-to to have on the forum.

Cheers.

Stu