FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » PHP Runs In WinXP Command Window But Not In Browser
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: PHP Runs In WinXP Command Window But Not In Browser [message #173412 is a reply to message #173406] Fri, 08 April 2011 18:17 Go to previous messageGo to previous message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma:
Senior Member
On Fri, 08 Apr 2011 10:34:12 -0700, Peter Lauren wrote:

> On Apr 7, 10:09 am, Denis McMahon <denis.m.f.mcma...@gmail.com> wrote:
>> Note, however, that you REALLY REALLY SHOULD NOT use "localhost" or
>> "127.0.0.1" in any url inside a file in the "DocumentRoot" directory or
>> it's sub directories, as the special dns entry and special ip address
>> will ONLY WORK if you are using a browser on the SAME MACHINE as the
>> webserver.
>>
>> So, for example if you want to include a link to the file at
>> "c:\wamp\www \index.php" inside the file "c:\wamp\www\index.htm" so
>> that you link from the htm file to the php file when DocumentRoot is
>> "c:\wamp\www", your link inside the htm file would look something like:

>> <a href="index.php">link text</a>

> That's where I have a problem. If I use <a href="index.php">link
> text</a> instead of <a href="http://localhost/Examples.php">link
> text</a>, it looks for the file in the directory where the html file is
> located instead of in the "DocumentRoot" directory.

Where do you expect it to look?

URLs can be shortened in many ways, when a URL is shortened browsers will
try and make sense of them, and servers will try and interpret what the
browser offers them, but if your browser asks a server for a file it
can't find, you'll get an error (which the browser may hide from you
while it tries something else)

You're obviously having problems understanding how urls relate to files
and servers.

A url such as "http://server/path/file.type" generally means go to the
web server "server" and ask it for "/path/file.type"

In the absence of anything that tells it otherwise in the configuration
file "/path/" usually maps in some fairly literal way to the directory
structure below whatever is configured as DocumentRoot, eg on your
windows machine, where DocumentRoot is (I think) "c:\wamp\www\", then if
"/path/" in the url was "/fred/jim/tony/" your server would be looking in
"c:\wamp\www\fred\jim\tony\" for a file called "file.type", which it
would then process according to any other instructions (such as things
that tell it what to do with ".php" files etc)

Now, a url may get shortened, to, for example "file.type", in which case,
when a browser requests "file.type" because a user has clicked on a link,
the browser will use the path information of the current file to build
the request.

This means that if you're looking at "http://server/joe/sue/file1.type1"
and click a link that was coded as '<a href="file2.type2">some text</a>'
then the web browser logic works something like:

I'm looking at "http://server/joe/sue/file1.type1" and now I want
"file2.type2" so I request "http://server/joe/sue/file2.type2"

and you would expect your server to deliver c:\wamp\www\joe\sue
\file2.type2

However, if the link was '<a href="/file2.type2">some text</a>', the
browser logic works something like:

I'm looking at http://server/joe/sue/file1.type1 and now I want "/
file2.type2" so I request "http://server/file2.type2"

and you would expect your server to deliver c:\wamp\www\file2.type2

The leading slash means "start at the webroot and work down"

There are other ways links can be specified:

".." means "up one directory level"

With '<a href="../alison/file2.type2">some text</a>' the browser logic
works something like:

I'm looking at "http://server/joe/sue/file1.type1" and now I want
"../alison/file2.type2" so I request "http://server/joe/alison/
file2.type2"

and you would expect your server to deliver c:\wamp\www\joe\alison
\file2.type2

and with '<a href="../file2.type2">some text</a>' the browser logic works
something like:

I'm looking at "http://server/joe/sue/file1.type1" and now I want
"../file2.type2" so I request "http://server/joe/file2.type2"

and you would expect your server to deliver c:\wamp\www\joe\file2.type2

Finally, a note of caution. If you use "localhost" or "127.0.0.1" as the
"server" in the urls in web pages on your computer, anyone trying to view
the web pages from from any other computer WILL get errors. If you wish
to specify absolute paths from the webroot, use

'href="http:/path/file.type"'

and not

'href="http://localhost/path/file.type"'

This is because when their web browser process "localhost" or "127.0.01",
it will try and ask a webserver running on their machine for the file
(because on their machine, localhost is their machine) and obviously,
even if they have a webserver running, it won't be using the files from
the DocumentRoot c:\wamp\www on your machine.

This really is outside the scope of comp.lang.php though.

I'm setting followups to comp.infosystems.www.authoring.html

Rgds

Denis McMahon
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: neither var_dump() nor die() displays anything
Next Topic: Spaces in filenames
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 30 00:01:15 GMT 2024

Total time taken to generate the page: 0.05258 seconds