Connecting Tech Pros Worldwide Forums | Help | Site Map

Capturing the entire URL

fartsniff
Guest
 
Posts: n/a
#1: Jul 17 '05
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 "redirection" now (btw, it is IIS (Win2k) and PHP
4.3.2)
The test.mydomain.com is setup as a host header under IIS

$redirect = getenv("HTTP_HOST");

if ($redirect=="test.mydomain.com"){
header("Location:http://www.mydomain.com/modules.php?name=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]
Guest
 
Posts: n/a
#2: Jul 17 '05

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 "redirection" now (btw, it is IIS (Win2k)
> and PHP 4.3.2)
> The test.mydomain.com is setup as a host header under IIS
>
> $redirect = getenv("HTTP_HOST");
>
> if ($redirect=="test.mydomain.com"){
> header("Location:http://www.mydomain.com/modules.php?name=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?name=$1 [L]


or something similar.

Forgive me if I'm wrong =)



Regards,

Ian

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

iQA/AwUBPzf6CGfqtj251CDhEQIjggCg/J2Ru64A9bSIGR8pORlXKzAiqMoAoN7r
FAKsAIVkowYNARM9gNR5M55c
=Yoop
-----END PGP SIGNATURE-----

--
Ian.H [Design & Development]
digiServ Network - Web solutions
www.digiserv.net | irc.digiserv.net | forum.digiserv.net
Programming, Web design, development & hosting.
Ian.H [dS]
Guest
 
Posts: n/a
#3: Jul 17 '05

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?name=$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/AwUBPzf9Qmfqtj251CDhEQJbpQCg+hnkB0ii3RCZ519uChtkQw duLTMAn3RW
jocp7IoLgUPTgH7WSNCkf/Pj
=y5Xw
-----END PGP SIGNATURE-----

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