473,466 Members | 1,360 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Why is localhost added to all my links ?

Not sure if this is a php, mysql, or apache issue. I use win2k and I
have AMP on my system as a localhost. I use this to test PHP/MYSQL
scripts I write on my local PC.

I render a URL w/PHP by reading the URL string from a mysql field, eg.
on the php web page it shows as eg. www.yahoo.com link

But when I click the link I see that "localhost" is added to the URL
and it goes nowhere. ie. it get localhost added to the front -
localhost/www.yahoo.com

Is there a setting somewhere so that the link is exactly what the link
is and localhost is not added.

Thanks
Jul 17 '05 #1
4 8404
.oO(Hal Halloway)
I render a URL w/PHP by reading the URL string from a mysql field, eg.
on the php web page it shows as eg. www.yahoo.com link

But when I click the link I see that "localhost" is added to the URL
and it goes nowhere. ie. it get localhost added to the front -
localhost/www.yahoo.com

Is there a setting somewhere so that the link is exactly what the link
is and localhost is not added.


Relative URLs are expanded with the current hostname. If you want to
link to external servers the URL has to start with http(s)://.

Micha
Jul 17 '05 #2
Hal Halloway wrote:
I render a URL w/PHP by reading the URL string from a mysql field, eg.
on the php web page it shows as eg. www.yahoo.com link

But when I click the link I see that "localhost" is added to the URL
and it goes nowhere. ie. it get localhost added to the front -
localhost/www.yahoo.com

Is there a setting somewhere so that the link is exactly what the link
is and localhost is not added.


When you construct the anchors without the "http://" prefix, all the targets
are expected to be on the same server.
JW

Jul 17 '05 #3
Hal Halloway wrote:

But when I click the link I see that "localhost" is added to the URL
and it goes nowhere. ie. it get localhost added to the front -
localhost/www.yahoo.com
looks like PHP has a couple of rules:

1. if you prefix a URL with http:// or just a /, then it leaves it alone.

i.e "http://www.happyhappybunnies.com"
"/showerror.php?err=342"
2. if you do neither of these, it prefixes them with a host name and /.

Is there a setting somewhere so that the link is exactly what the link
is and localhost is not added.
best choice would be to prefix full URLs with http:// and relative URLs
with /.

PHP does have a mechanism via which you can control what markup elements
it modifies on output, which somehow ties into the url_rewriter.tags entry
in the php.ini file. i haven't studied this too much, so i'm not 100%
certain how it works.

good ruck!

mark.

Thanks


--
I am not an ANGRY man. Remove the rage from my email to reply.
Jul 17 '05 #4
.oO(Mark)
Hal Halloway wrote:
But when I click the link I see that "localhost" is added to the URL
and it goes nowhere. ie. it get localhost added to the front -
localhost/www.yahoo.com
looks like PHP has a couple of rules:


It's not a PHP issue.
1. if you prefix a URL with http:// or just a /, then it leaves it alone.

i.e "http://www.happyhappybunnies.com"
"/showerror.php?err=342"

2. if you do neither of these, it prefixes them with a host name and /.
The user agent (browser) expands URLs if necessary, not the server. Have
a look at the generated HTML to see what PHP did send to the browser.
PHP does have a mechanism via which you can control what markup elements
it modifies on output, which somehow ties into the url_rewriter.tags entry
in the php.ini file. i haven't studied this too much, so i'm not 100%
certain how it works.


This only applies to session handling.

Micha
Jul 17 '05 #5

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

Similar topics

15
by: Michael Rybak | last post by:
hi, everyone. I'm writing a 2-players game that should support network mode. I'm now testing it on 1 PC since I don't have 2. I directly use sockets, and both client and server do...
1
by: krian | last post by:
Hi, I need a help from anybody. My problem is here I wrote two WebApplication in ASP.net Using C#. The name of the applications are (Journal.aspx and Payment.aspx). These Two pages have DataGrids...
23
by: darrel | last post by:
I'm trying to figure out if I can run to localhost sites at once. Such as 'localhost' and 'site2.localhost'. It appears I can set both of them up, but not run them at the same time. Is that...
6
by: Brad | last post by:
I have a win2003 server workstation with multiple webs, each web has it's own ip address. In VS2005, if I select to open an existing web site, select Local IIS, the dialog correctly displays a...
3
by: Lee Roth | last post by:
I am testing a web app that links to user defined URLs. I want the link to be the exact text the user provided but I can't seem to get rid of the "http://localhost" prefix in the link. Note that I...
5
by: Howard | last post by:
I develop my website locally with VS 2005. the problem is all the links are broken because the directories don't match. on my production server it's www.myname.com/ but on my local server it's...
12
by: John Kotuby | last post by:
Hi all, Maybe this is a simple problem found in ASP.NET 2.0 course 101, but I must have missed it. When I create a page in Visual Web Developer and use URLs like "/images/picture.gif " or a link...
6
by: MaiyaHolliday | last post by:
Hello, I've recently installed apache on a new computer, and cannot figure out why my site will not process any includes. (it was working on my old one) There are no errors on the page such as...
7
by: pek | last post by:
OK, I've been having this problem for quite some time but never until now I really needed a solution. I have never thought of a work around, so I really need your help. Sorry if this has been...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.