473,404 Members | 2,179 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

URL Component

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.
Oct 15 '08 #1
2 1378
Hi

On Wed, 15 Oct 2008 09:03:10 -0700, bgold12 wrote:
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.
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
Oct 15 '08 #2
bgold12 escribió:
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.

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
--
Oct 15 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Edward Diener | last post by:
How does one specify in a component that a property is a pointer to another component ? How is this different from a property that is actually an embedded component ? Finally how is one notified in...
2
by: AMDRIT | last post by:
Hello everyone, I have created a custom component and one of its properties is a class object with it's own properties. During runtime, I can assign values to the class object properties just...
122
by: Edward Diener No Spam | last post by:
The definition of a component model I use below is a class which allows properties, methods, and events in a structured way which can be recognized, usually through some form of introspection...
7
by: Joe | last post by:
Is it possible to have a component which is global to the entire application? I need to have a single component act sort of like a server which components in any of the forms can access. For...
0
by: bharathreddy | last post by:
In .Net COM+ components are referred to as serviced components, Namespace: System.EnterpriseServices; Advantage of Serviced Components: object pooling, database connection pooling,
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.