Capturing the entire URL

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

    #1

    Capturing the entire URL

    Hello all,
    Been playing around with capturing the entire URL. I dont have any problems
    if it a file,
    i.e. http://www.mydomain.com/somefile.php, I am running into problems with
    this,


    This is what I use for "redirectio n" now (btw, it is IIS (Win2k) and PHP
    4.3.2)
    The test.mydomain.c om is setup as a host header under IIS

    $redirect = getenv("HTTP_HO ST");

    if ($redirect=="te st.mydomain.com "){
    header("Locatio n:http://www.mydomain.co m/modules.php?nam e=test");
    }

    The above code works fine. Redirects no problem.

    However, I am trying to get this to do the same thing:
    www.mydomain.com/test or www.mydomain.com/test/
    and both would take you here:
    http://www.mydomain.com/modules.php?name=test

    I have tried every combination of the SERVER vars, but no luck.
    I either generate a 404 or the test isn't part of the URL.

    Any ideas ?


  • Ian.H [dS]

    #2
    Re: Capturing the entire URL

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    Whilst lounging around on Mon, 11 Aug 2003 11:18:29 -0800,
    "fartsniff" <fart@sniff.com > amazingly managed to produce the
    following with their Etch-A-Sketch:
    [color=blue]
    > Hello all,
    > Been playing around with capturing the entire URL. I dont have any
    > problems if it a file,
    > i.e. http://www.mydomain.com/somefile.php, I am running into
    > problems with this,
    > http://www.mydomain.com/test
    >
    > This is what I use for "redirectio n" now (btw, it is IIS (Win2k)
    > and PHP 4.3.2)
    > The test.mydomain.c om is setup as a host header under IIS
    >
    > $redirect = getenv("HTTP_HO ST");
    >
    > if ($redirect=="te st.mydomain.com "){
    > header("Locatio n:http://www.mydomain.co m/modules.php?nam e=test");
    > }
    >
    > The above code works fine. Redirects no problem.
    >
    > However, I am trying to get this to do the same thing:
    > www.mydomain.com/test or www.mydomain.com/test/
    > and both would take you here:
    > http://www.mydomain.com/modules.php?name=test
    >
    > I have tried every combination of the SERVER vars, but no luck.
    > I either generate a 404 or the test isn't part of the URL.
    >
    > Any ideas ?
    >[/color]


    $_SERVER['REQUEST_URI'] should contain the stuff after the
    domain.com/ part.

    I'm sure you have good reasons.. but to me personally, this looks
    like you're attempting to get PHP to do something that is best suited
    to the server via mod_rewrite:


    RewriteRule ^/(.*)/$ /modules.php?nam e=$1 [L]


    or something similar.

    Forgive me if I'm wrong =)



    Regards,

    Ian

    -----BEGIN PGP SIGNATURE-----
    Version: PGP 8.0

    iQA/AwUBPzf6CGfqtj2 51CDhEQIjggCg/J2Ru64A9bSIGR8p ORlXKzAiqMoAoN7 r
    FAKsAIVkowYNARM 9gNR5M55c
    =Yoop
    -----END PGP SIGNATURE-----

    --
    Ian.H [Design & Development]
    digiServ Network - Web solutions
    www.digiserv.net | irc.digiserv.ne t | forum.digiserv. net
    Programming, Web design, development & hosting.

    Comment

    • Ian.H [dS]

      #3
      Re: Capturing the entire URL

      -----BEGIN PGP SIGNED MESSAGE-----
      Hash: SHA1

      Whilst lounging around on Mon, 11 Aug 2003 12:31:48 -0800,
      "fartsniff" <fart@sniff.com > amazingly managed to produce the
      following with their Etch-A-Sketch:
      [color=blue]
      > but isnt RewriteRule ^/(.*)/$ /modules.php?nam e=$1 [L]
      > only for apache ?
      >
      > i am using iis on win2k.[/color]


      [ looks around for some of that coffee ]


      Indeed FS =[


      The $_SERVER['REQUEST_URI'] should grab / display the info you
      require for a PHP solution =)

      Apologies for the misreading / confusion.



      Regards,

      Ian

      -----BEGIN PGP SIGNATURE-----
      Version: PGP 8.0

      iQA/AwUBPzf9Qmfqtj2 51CDhEQJbpQCg+h nkB0ii3RCZ519uC htkQwduLTMAn3RW
      jocp7IoLgUPTgH7 WSNCkf/Pj
      =y5Xw
      -----END PGP SIGNATURE-----

      --
      Ian.H [Design & Development]
      digiServ Network - Web solutions
      www.digiserv.net | irc.digiserv.ne t | forum.digiserv. net
      Programming, Web design, development & hosting.

      Comment

      Working...