Random question
I've been wondering this for awhile now and I've never been able to figure out.
I have a URL, let's say http://www.blah.org/test.php, and I want to use it like this: http://www.blah.org/test.php/variables. How would I go about extracting the variables part from the URL. Something like this site does.
Thanks,
necrotic
[James Logsdon]
Renegade posted this at 01:17 — 6th December 2002.
He has: 3,022 posts
Joined: Oct 2002
y would u want to do that?
necrotic posted this at 01:43 — 6th December 2002.
He has: 296 posts
Joined: May 2002
Just something else to add to my 'vast amounts of knowledge':)
Busy posted this at 04:48 — 6th December 2002.
He has: 6,151 posts
Joined: May 2001
if you do it like blah.zz/name.php?variable=something you can just print or echo the variable name echo $variable; and you should get 'something' on the screen.
the other way is using explode, I've only used it to get the domain section like so: $url = explode("/", $HTTP_REFERER); and it will give you what is before the /
hopefully the experts can explain or use it in a better way
Mark Hensler posted this at 08:00 — 6th December 2002.
He has: 4,048 posts
Joined: Aug 2000
The most popular reason for doing this is so that it's more search engine friendly. (Some engines dislike question marks)
The best option, IMO, is to use .htaccess. You'll use mod_rewrite to find any REQUEST_URI that contain your filename as a directory, then re-write the path to your script with a properly formated querystring.
http://httpd.apache.org/docs/misc/rewriteguide.html
http://www.phpfreaks.com/tutorials/23/1.php
http://soysal.com/article.php?sid=5
http://www.linux.ie/pipermail/webdev/2001-March/001216.html
http://www.evolt.org/article/Making_clean_URLs_with_Apache_and_PHP/18/22880/?format=print
Mark Hensler
If there is no answer on Google, then there is no question.
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.