Connecting Tech Pros Worldwide Help | Site Map

URL Component

  #1  
Old October 15th, 2008, 05:05 PM
bgold12
Guest
 
Posts: n/a
Hey, I know that in a URL there's generally the "scheme" (i.e. http://),
followed by the hostname or domain name (i.e. en.wikipedia.org/)
followed by possible subfolders (i.e. /wiki/) which can then be
followed by the name of a file to send the request to (i.e. index.html
or index.php or something). There can also be GET data (i.e. ?
name=value) and the anchor thing (i.e. #Chapter_1). But also,
frequently there's just a string that finishes the URL, which doesn't
appear to be a folder (no trailing forward slash) or a file (no
extension), for example:

http://en.wikipedia.org/wiki/Uniform_Resource_Locator

Can someone explain to me what this string (i.e.
"Uniform_Resource_Locator" in the above example) is, and how you can
use php to get it?

Thanks.
  #2  
Old October 15th, 2008, 05:25 PM
viza
Guest
 
Posts: n/a

re: URL Component


Hi

On Wed, 15 Oct 2008 09:03:10 -0700, bgold12 wrote:
Quote:
Hey, I know that in a URL there's generally the "scheme" (i.e. http://),
followed by the hostname or domain name (i.e. en.wikipedia.org/)
followed by possible subfolders (i.e. /wiki/) which can then be followed
by the name of a file to send the request to (i.e. index.html or
index.php or something). There can also be GET data (i.e. ? name=value)
and the anchor thing (i.e. #Chapter_1). But also, frequently there's
just a string that finishes the URL, which doesn't appear to be a folder
(no trailing forward slash) or a file (no extension), for example:
>
http://en.wikipedia.org/wiki/Uniform_Resource_Locator
1) Files do not have to have have "extensions" on modern systems.

2) Web addresses do not have to refer to files.

http://example.org/fooo...barrr

is a valid URL even on some systems where foo...bar is not a valid
filename.

Moreover the part after the third slash and before the final slash does
not have to refer to a directory, although if relative URLs contain ../
then it they are treated as if it does.

PS: you duplicated the third slash - it is not part of the domain.
Quote:
and how you can use php to get it?
There are all sorts of ways to open a remote resource in php. IIRC you
can just do:

$foo= file( 'http://en.wikipedia.org/wiki/Uniform_Resource_Locator' );

HTH
viza
  #3  
Old October 15th, 2008, 05:25 PM
=?ISO-8859-1?Q?=22=C1lvaro_G=2E_Vicario=22?=
Guest
 
Posts: n/a

re: URL Component


bgold12 escribió:
Quote:
Hey, I know that in a URL there's generally the "scheme" (i.e. http://),
followed by the hostname or domain name (i.e. en.wikipedia.org/)
followed by possible subfolders (i.e. /wiki/) which can then be
followed by the name of a file to send the request to (i.e. index.html
or index.php or something).
URLs don't need to match physical files and directories on the server
(and often don't). A simple example is when you omit "index.html" in the
URL and get the "index.html" file anyway. But you can configure your
webserver to map any URL to any resource.

So distinguishing between files and directories is normally meaningless.

Quote:
Can someone explain to me what this string (i.e.
"Uniform_Resource_Locator" in the above example) is, and how you can
use php to get it?
The short answer is that you don't use PHP for this. Instead, you
configure your web server to run (e.g.)
/home/foo/fetch-article.php?query=Uniform_Resource_Locator and read
input from good old $_GET['query']. The typical option is Apache's
mod_rewrite:

http://httpd.apache.org/docs/2.2/en/rewrite/

You might also enjoy:

http://httpd.apache.org/docs/2.2/en/...gotiation.html
http://httpd.apache.org/docs/2.2/en/urlmapping.html



--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
URL Component bgold12 answers 2 October 15th, 2008 05:25 PM
Python component model Edward Diener No Spam answers 122 November 13th, 2006 04:45 PM
Thumbnail from URL component required Daren Hawes answers 1 July 25th, 2006 12:25 PM
Regd Vector Draw Component in Visual Basic Raja answers 3 July 17th, 2005 10:15 PM