By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,829 Members | 2,308 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,829 IT Pros & Developers. It's quick & easy.

Capturing the entire URL

P: n/a
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 ?
Jul 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Whilst lounging around on Mon, 11 Aug 2003 11:18:29 -0800,
"fartsniff" <fa**@sniff.com> amazingly managed to produce the
following with their Etch-A-Sketch:
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 ?

$_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.
Jul 16 '05 #2

P: n/a
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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

i am using iis on win2k.

[ 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.
Jul 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.