• URL redirection question

    From Ivan Shmakov@21:1/5 to All on Thu Jun 29 18:33:43 2017
    XPost: comp.protocols.tcp-ip

    Barry Margolin <barmar@alum.mit.edu> writes:
    bit-naughty@hotmail.com wrote:

    [Cross-posting to news:comp.infosystems.www.misc, for reasons.]

    I just got a bill on my phone, which said "To pay this bill - go to
    www.<whatever>" . When I went to the site - it said stuff like
    "Welcome Mr. John Doe", ie. it *knew from the URL* that it was me!
    I'm kind of trying to figure out how this was architected - can you
    guys help? :)

    MY brain suggested something like this: whatever was after the "/"
    in the URL (something like e2gbm853dc or whatever) was an ARGUMENT -
    when someone types that in to the browser, it redirects to
    script.php (or whatever) on the server with THAT string as the
    argument. Which, by querying for that row in a SQL database or
    something, brings up my name in the company's database..... am I on
    the right track here?

    Yes, that's basically how it works. Webservers typically use rewrite
    rules to move path components to script parameters, so a URL like:

    https://www.example.com/paybill/e2gbm853dc

    could be translated to:

    https://www.example.com/paybill.php?id=e2gbm853dc

    and then the script does the database lookup to find you.

    Or the Web server could be configured so that whenever it sees a
    URI starting with "/paybill", it starts (or contacts, for
    FastCGI) the script, which then has access to either the
    original URI in its entirety, or at least the part after the
    script's name.

    I'm pretty sure that configuring Apache in such a way may be a
    matter of a couple of lines. (Like SetHandler, etc.)

    --
    FSF associate member #7257 np. Most Wonderful of Nights -- Aftermath

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Eli the Bearded@21:1/5 to ivan@siamics.net on Thu Jun 29 22:31:49 2017
    XPost: comp.protocols.tcp-ip

    In comp.infosystems.www.misc, Ivan Shmakov <ivan@siamics.net> wrote:
    Barry Margolin <barmar@alum.mit.edu> writes:
    bit-naughty@hotmail.com wrote:
    [Cross-posting to news:comp.infosystems.www.misc, for reasons.]

    Hellow from ciwm!

    Yes, that's basically how it works. Webservers typically use rewrite rules to move path components to script parameters, so a URL like: https://www.example.com/paybill/e2gbm853dc
    could be translated to:
    https://www.example.com/paybill.php?id=e2gbm853dc

    That sounds like such an old-fashioned way to do it. Why bother with a
    rewrite when you can just use the original?

    Or the Web server could be configured so that whenever it sees a
    URI starting with "/paybill", it starts (or contacts, for
    FastCGI) the script, which then has access to either the
    original URI in its entirety, or at least the part after the
    script's name.

    In modern web frameworks, the local part of the URL (the URI) is called
    a "route" and the routing table in the framework is consulted. Consider
    Ruby on Rails:

    http://guides.rubyonrails.org/routing.html

    The very first example is relevant here. Some other frameworks might
    solve this by having the server always return the same page for all of /paybill/*, and a javascript routing table examine the URL and look up
    the content to fill in to the page. For example, Ember:

    https://guides.emberjs.com/v2.12.0/routing/defining-your-routes/

    Look at the Dynamic Routes section.

    Elijah
    ------
    the wab has so many ways to ensnare you now

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)