anchors

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ben Wilson

    anchors

    To anyone who can help me, you have my thanks in advance.

    I am implementing a "301 Moved Permanently" redirect in my website due to a
    change of our domain names. Unfortunately, I am having a problem with
    reconstructing the target "Location" http header because I'm missing just
    one thing.

    My links look as follows:



    This I need to change to the following:



    As you can see, it's no BIG deal. All I need to change is the start and all
    the rest can stay the same. So I need to create the new URL as a string so I
    can call the following:

    header("HTTP/1.1 301 Moved Permanently");
    header($locatio nstring);
    exit;

    That's all.

    First, I recreate the "server name" with the following two lines of code:

    $oldurl = $_SERVER['HTTP_HOST'];
    $newurl = str_replace("ol durl.com", "newurl.org ", $oldurl);

    Next, I can recreate the file name ("beanie.php ") with the following line of
    code:

    $locationstring = ("Location: http://".$newurl.$_SER VER['PHP_SELF']);

    Now I've got http://www.newurl.org/beanie.php.

    The two GET vars "register" and "demt" I can access with

    $registercode = $HTTP_GET_VARS["register"];
    $articlecode = $HTTP_GET_VARS["demt"];

    But how do I get the anchor!?!?!?!? How do I know if there was one and if so
    what it was (the #three bit above).

    Many thanks,

    Ben.



  • Eric Bohlman

    #2
    Re: anchors

    "Ben Wilson" <pleaseno@spam. com> wrote in
    news:4090fbc4$0 $22994$a0ced6e1 @news.skynet.be :
    [color=blue]
    > I am implementing a "301 Moved Permanently" redirect in my website due
    > to a change of our domain names. Unfortunately, I am having a problem
    > with reconstructing the target "Location" http header because I'm
    > missing just one thing.
    >
    > My links look as follows:
    >
    > http://www.oldurl.com/beanie.php#thr...=false&demt=43
    >
    > This I need to change to the following:
    >
    > http://www.newurl.org/beanie.php#thr...=false&demt=43[/color]

    [snip]
    [color=blue]
    > But how do I get the anchor!?!?!?!? How do I know if there was one and
    > if so what it was (the #three bit above).[/color]

    Unfortunately, you can't. Browsers don't send out fragment identifiers
    when they make requests. If someone follows your old link, the browser is
    going to ask the server for "beanie.php?reg ister=false&dem t=43" and, once
    it gets a response, go looking for an id or named anchor called "three" in
    the response.

    Comment

    • Ben Wilson

      #3
      Re: anchors


      "Eric Bohlman" <ebohlman@earth link.net> wrote in message
      news:Xns94DA5B0 D62F21ebohlmano msdevcom@130.13 3.1.4...[color=blue]
      > "Ben Wilson" <pleaseno@spam. com> wrote in
      > news:4090fbc4$0 $22994$a0ced6e1 @news.skynet.be :
      >[color=green]
      > > I am implementing a "301 Moved Permanently" redirect in my website due
      > > to a change of our domain names. Unfortunately, I am having a problem
      > > with reconstructing the target "Location" http header because I'm
      > > missing just one thing.
      > >
      > > My links look as follows:
      > >
      > > http://www.oldurl.com/beanie.php#thr...=false&demt=43
      > >
      > > This I need to change to the following:
      > >
      > > http://www.newurl.org/beanie.php#thr...=false&demt=43[/color]
      >
      > [snip]
      >[color=green]
      > > But how do I get the anchor!?!?!?!? How do I know if there was one and
      > > if so what it was (the #three bit above).[/color]
      >
      > Unfortunately, you can't. Browsers don't send out fragment identifiers
      > when they make requests. If someone follows your old link, the browser is
      > going to ask the server for "beanie.php?reg ister=false&dem t=43" and, once
      > it gets a response, go looking for an id or named anchor called "three" in
      > the response.[/color]


      Excellent! Then I don't even have to bother returning it! I can just forget
      about it, for the browser will pick it up automatically! This exceeds my
      expectations by far, by very far. In fact, it couldn't get any better. Thank
      you,

      Ben.




      Comment

      • John Dunlop

        #4
        Re: anchors

        Ben Wilson wrote:

        [ ... ]
        [color=blue]
        > http://www.oldurl.com/beanie.php#thr...=false&demt=43
        >
        > This I need to change to the following:
        >
        > http://www.newurl.org/beanie.php#thr...=false&demt=43[/color]

        Cool, a dot com becomes a dot org; and "beanie"'s got me intrigued
        too. But I can't access either. If those are examples, will you be
        kind enough to post the actual URIs, please?

        It's better to use the reserved TLD ".example" for examples (RFC2606).

        [ ... ]
        [color=blue]
        > The two GET vars "register" and "demt"[/color]

        Those URIs have no query components: there are no "GET vars". Did you
        just write them wrongly here?

        --
        Jock

        Comment

        • Ben Wilson

          #5
          Re: anchors


          "John Dunlop" <usenet+2004@jo hn.dunlop.name> wrote in message
          news:MPG.1afb32 d35e13bec398970 6@News.Individu al.NET...

          [color=blue]
          > Cool, a dot com becomes a dot org; and "beanie"'s got me intrigued
          > too. But I can't access either. If those are examples, will you be
          > kind enough to post the actual URIs, please?
          >
          > It's better to use the reserved TLD ".example" for examples (RFC2606).[/color]

          Dear John:

          Thank you for bringing RFC2606 to my attention. I am pleased to provide you
          with the corrected URIs which I hope you will find less confusing:





          [color=blue][color=green]
          > > The two GET vars "register" and "demt"[/color]
          >
          > Those URIs have no query components: there are no "GET vars". Did you
          > just write them wrongly here?[/color]


          I'm sorry, I thought "register" was a GET var here equal to "false" and that
          "demt" was a GET var equal to "43". Euhm, am I misunderstandin g something?

          [color=blue]
          >
          > --
          > Jock[/color]


          Comment

          • Virgil Green

            #6
            Re: anchors

            "Ben Wilson" <pleaseno@spam. com> wrote in message
            news:409253d3$0 $21781$a0ced6e1 @news.skynet.be ...[color=blue]
            >
            > "John Dunlop" <usenet+2004@jo hn.dunlop.name> wrote in message
            > news:MPG.1afb32 d35e13bec398970 6@News.Individu al.NET...
            >
            >[color=green]
            > > Cool, a dot com becomes a dot org; and "beanie"'s got me intrigued
            > > too. But I can't access either. If those are examples, will you be
            > > kind enough to post the actual URIs, please?
            > >
            > > It's better to use the reserved TLD ".example" for examples (RFC2606).[/color]
            >
            > Dear John:
            >
            > Thank you for bringing RFC2606 to my attention. I am pleased to provide[/color]
            you[color=blue]
            > with the corrected URIs which I hope you will find less confusing:
            >
            > http://www.oldhost.invalid/foo.php#t...=false&demt=43
            >
            > http://www.newhost.invalid/foo.php#t...=false&demt=43[/color]

            I can't stand the suspense... You don't have a query component because
            you've put the anchor ahead of what you seem to think is the query string.
            If you moved the anchor to the end where it belongs, you'll have a query
            string (set of query parameters).
            [color=blue][color=green][color=darkred]
            > > > The two GET vars "register" and "demt"[/color]
            > >
            > > Those URIs have no query components: there are no "GET vars". Did you
            > > just write them wrongly here?[/color]
            >
            >
            > I'm sorry, I thought "register" was a GET var here equal to "false" and[/color]
            that[color=blue]
            > "demt" was a GET var equal to "43". Euhm, am I misunderstandin g something?[/color]

            yes... or so it seems.

            - Virgil


            Comment

            • John Dunlop

              #7
              Re: anchors

              Ben Wilson wrote:
              [color=blue]
              > http://www.newhost.invalid/foo.php#t...=false&demt=43[/color]

              [ ... ]
              [color=blue]
              > I'm sorry,[/color]

              No need to apologise!
              [color=blue]
              > I thought "register" was a GET var here equal to "false" and that
              > "demt" was a GET var equal to "43".[/color]

              There is no query component here, no "GET vars" if you like, because
              everything after the "#" is the fragment identifier and technically
              not part of the URI. Besides, as Eric says, it's not even *given* to
              the server; the user-agent keeps it and applies it to the retrieved
              resource; as for text/html bodies, which presumably yours is,

              | ... the fragment identifier designates the correspondingly named
              | element; any element may be named with the "id" attribute, and A,
              | APPLET, FRAME, IFRAME, IMG and MAP elements may be named with a
              | "name" attribute.

              RFC2854, "The 'text/html' Media Type",


              As Virgil Green has said, fix this by moving "#three" to the end:



              The query component is now "register=false &demt=43" and the fragment
              identifier is "three".
              [color=blue]
              > Euhm, am I misunderstandin g something?[/color]

              I didn't elaborate on my apology for an explanation before because I
              thought you just muddled up the parts of the URI references in your
              article and wouldn't have appreciated it. Perhaps I was mistaken.

              I'd still like to see the actual website! ;-)

              --
              Jock

              Comment

              • Ben Wilson

                #8
                Re: anchors


                "John Dunlop" wrote:[color=blue]
                >[color=green]
                > > http://www.newhost.invalid/foo.php#t...=false&demt=43[/color]
                >
                > [ ... ]
                >
                >
                > There is no query component here, no "GET vars" if you like, because
                > everything after the "#" is the fragment identifier and technically
                > not part of the URI. Besides, as Eric says, it's not even *given* to
                > the server; the user-agent keeps it and applies it to the retrieved
                > resource; as for text/html bodies, which presumably yours is,
                >
                > | ... the fragment identifier designates the correspondingly named
                > | element; any element may be named with the "id" attribute, and A,
                > | APPLET, FRAME, IFRAME, IMG and MAP elements may be named with a
                > | "name" attribute.
                >[/color]

                Thank you (and Virgil) for your help. I understand what you are referring
                to. The hypothetical URL I've taken here as an example is misformed.
                Actually this is because there are no pages on the site that combine both
                get vars and anchors. I realised for the pages that used get vars I could
                reproduce the get vars by accessing the array, but for the pages that used
                anchors I could not reproduce the anchors. I had never actually had to
                implement both features at once.

                I don't check out newsgroups often but I am surprised by everyone's interest
                to see the website I'm working on. (Yes, the pages do have the extension of
                asp but this is because we made a migration from asp to php and we haven't
                gotten round to changing the extensions. That will be a next project.)

                I will keep you in suspense no longer. An example of a page from our site
                that uses getvars is



                An example of a page from our site that uses anchors is

                http://www.falconsoft. be/careers!main.as p#02

                All the best,

                Ben.

                [color=blue]
                >
                > I'd still like to see the actual website! ;-)
                >
                > --
                > Jock[/color]


                Comment

                Working...