This is a discussion on Why is localhost added to all my links ? within the PHP Language forums, part of the PHP Programming Forums category; Not sure if this is a php, mysql, or apache issue. I use win2k and I have AMP on my ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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 |
|
|||
|
.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 |
|
|||
|
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 |
|
|||
|
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. |
|
|||
|
.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 |