Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • URL redirection with -net from-

    Will -net from <directory_or_url>- accept a URL redirect?
    And, if so, is there a particular technique that should be used to set up the redirection?

    I am asking this with almost complete ignorance about URL redirection but am guessing that most approaches target browsers and will not be recognized by Stata.

    In the past we have made several Stata packages available from a user site with a reasonably simple URL. My institution has recently redesigned and reorganized investigator websites and pages such that my Stata usersite now resides in a location 7 subdirectories deep with a 99 character URL!

    Our system admin has offered to set up a short URL with a redirect to the longer URL, but I wasn't sure if or how this would work with Stata's -net- command.

    Thanks!
    - Gary

  • #2
    Not 100% positive, and there are several ways to set up re-directs, to which Stata may react differently.
    1. Redirect at the CNAME level, possibly in concert with virtual directories (2, below). This is almost certain to work. Need to manipulate the DNS server(s) to have multiple addresses pointing at the same host. To your browser (and Stata) all looks normal, unless you have SSL. The routers are pulling up one host-name and serving it up as another.
    2. Redirect at the virtual directory level, that is, a short, two-level deep directory points at your seven-directory-deep folder. Again, should work, since to your browser (or Stata), all looks normal. The web-server is pulling information from one folder and serving it up as another.
    3. Redirect by putting a script in a folder. This approach is nice, since you can, for example, have it show a message that "This URL has moved. Update your links to [whatever]". Can be nice for web browsers and web crawlers like Google or Bing, but this is almost certain to fail for Stata.
    So if they have step 2 in place, should be covered; step 1 might help. But the proof is in the pudding: have them try it! It *should* work.

    Comment


    • #3
      Oh, and I left out the last-dtich approach to re-directs: manipulating the error pages/codes to something smart. Which is really cool (in some ways) since you don't need to copy the same file to replace all the missing pages like with stage 3. This (stage 4) is sure to foul up Stata. But if they fix things at level 1 (if needed if the server's name changed) and level 2 (because the directory structure changed), it's moot. As a sys-admin, I've done all four approaches depending on the situation. 1 and 2 should be totally transparent to Stata; it won't know the difference since stuff is being handled by the DNS server(s) and the web-server. Again, give them your limited trust and see if they can get it right. It's technically possible.
      Last edited by ben earnhart; 29 Aug 2014, 16:39.

      Comment


      • #4
        I don't believe that net will follow an HTTP redirect (i.e., status code 301). What you need to do instead is to use URL rewriting—a technique whereby the server internally redirects one URL to another in a way that is transparent to the client. This is easy to do in either Apache (via mod_rewrite) or Nginx. Hopefully, your sysadmin will be willing to do this for you.

        Requesting a dedicated CNAME is certainly an option, but this will require somewhat more effort both on your part and on the part of your sysadmin (you would then, in effect, have your own virtual server). The advantage is that you will then have a personal URL (e.g., http://yourname.yourorganization.org/stata). However, if you don't need this, then it's probably not worth doing.

        Finally, if your sysadmin is not able to provide you with a short URL, then I would suggest using GitHub Pages. This will permit you to set up a URL like
        http://glongton.github.io
        for free, and also make it easy to manage your site.

        Comment


        • #5
          The "virtual directory" option won't return a 301, rather, it will do what you call "URL rewriting" Same concept, different terminology between IIS and Apache. But IIS or Apache, yes, his Sys-Admin should be able to do it. But the proof is in the pudding.

          Sorry I may have confused matters by even mentioning options 3 and 4, and changing CNAMEs is probably not needed, though it could make sense organizationally.

          Comment


          • #6
            Originally posted by ben earnhart View Post
            The "virtual directory" option won't return a 301, rather, it will do what you call "URL rewriting" Same concept, different terminology between IIS and Apache.
            I was assuming that the OP was asking about an HTTP redirect, based on his post. But yes, if a "virtual directory" achieves the same thing as URL rewriting, then we're agreed that this is the best option in this case.

            Comment


            • #7
              A few years ago Notre Dame decided we'd all be much much happier if our web pages started with www3 instead of www. When you type a URL into a browser it redirects fine but it won't work when you use the use command. That is a minor nuisance but this seems to be a much bigger problem.
              -------------------------------------------
              Richard Williams, Notre Dame Dept of Sociology
              StataNow Version: 19.5 MP (2 processor)

              EMAIL: [email protected]
              WWW: https://www3.nd.edu/~rwilliam

              Comment


              • #8
                Originally posted by Gary Longton View Post
                Will -net from <directory_or_url>- accept a URL redirect?
                And, if so, is there a particular technique that should be used to set up the redirection?

                I am asking this with almost complete ignorance about URL redirection but am guessing that most approaches target browsers and will not be recognized by Stata.

                In the past we have made several Stata packages available from a user site with a reasonably simple URL. My institution has recently redesigned and reorganized investigator websites and pages such that my Stata usersite now resides in a location 7 subdirectories deep with a 99 character URL!

                Our system admin has offered to set up a short URL with a redirect to the longer URL, but I wasn't sure if or how this would work with Stata's -net- command.

                Thanks!
                - Gary
                Gary, the behavior may depend on the version of Stata. I have requested Stata to follow redirects when suggested by the server when I had encountered this problem before:
                http://hsphsun3.harvard.edu/cgi-bin/...icle-1155.html

                There are some security concerns about it, but in the end, by installing anything from the server you declare that you trust it. Whether it will cheat you directly by redirecting somewhere, or behind the scenes (by substituting a different content) is not that important.

                Recent version of Stata (13) seem to obey the redirection:
                http://www.statalist.org/forums/foru...-with-stata-13

                But as the picture shows, Stata 12 will not obey it.

                My recommendation would be that your institution grants you access to the file http://myorgname.com/stata.toc Giving exceptional write access to one file, which is visible to Stata only is usually an easy and acceptable solution. (but will reveal the full list of packages to every user, something I am avoiding on my own site). The packages themselves you will place in your own subdirectory, It shouldn't matter how deep or unreadable it is. The users will see the list of the packages in stata.toc and click their names to install.

                Best, Sergiy Radyakin

                Comment


                • #9
                  Ben, Phil, and Sergiy,

                  Thanks so much for your replies and suggestions.
                  I've passed these along via the thread link to our Sys admin.

                  I don't know enough about this area to understand some of the suggestions very well, but it sounds like Ben's virtual directory approach and Phil's URL rewriting should be hopeful solutions?

                  Have also asked about the possibility of obtaining exceptional write access to a low level institutional address/directory for just the .toc file per Sergiy's suggestion, though don't know yet if this will be permitted.

                  In any case it should ideally be a solution that works with earlier versions of Stata, as this is for packages that we have made publicly available to all Stata users.

                  I will keep Phil's Github suggestion in mind if a local solution doesn't work out.

                  Thanks again!

                  - Gary

                  Comment

                  Working...
                  X