473,545 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
+ 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 8435
.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.happyhappyb unnies.com"
"/showerror.php?e rr=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.ta gs 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.happyhappyb unnies.com"
"/showerror.php?e rr=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.ta gs 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
4455
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 computations, the only data transfered is user mouse/kbd input. It works synchronously, but somehow, when I play in client window, both client and ...
1
1758
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 in each page and links to the other page(Journal.aspx contain Payment.aspx link and Payment.aspx contain Journal.aspx link) Suppose we added...
23
1719
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 true? If so, what was MS thinking? Ugh. Alternatively, is there a practical way to have a site run from a directory within your root folder and...
6
3615
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 list of all of my webs, however if I attempt to open a site under and web other than localhost I receive the message: "Unable to open the Web...
3
5055
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 am user defined email addresses for "mailto:" links and the same problem occurs. Is this something that will be removed when the site is...
5
1425
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 localhost/myname/ it's there a way around this without having to manually change all the links? thanks, Howard
12
3834
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 like <a href="../../Search/page.aspx">, everything works fine as long as I publish the site to a root web like http://localhost. However, I am...
6
7960
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 "include not found", rather much of the page is blank where the included menus, etc would be, and the CSS is not attached. thanks so much!!! ...
7
2377
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 mentioned already. You can point me to the post and I'll gladly read. I googled this a lot but, first, most people have tutorials for sharing sessions in...
0
7405
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7659
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7760
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5334
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4949
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3455
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3444
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1887
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 we have to send another system
0
709
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.