Relative links with change of port

R

rach

Hi,

I'd like to know if I can use a relative link with change of port. So:

When on server http://123.123.123.123/index.html I could click a relative
link to go to 123.123.123.123:81/index.html . I know I could write a tag
like this:

<a href="http://123.123.123.123:81/index.html">link</a>

But I would like it so I could use it with an ever changing ip address that
I wouldn't need to change the html file.

So how would I write that tag?

Thanks!

Rach
 
T

Toby A Inkster

rach said:
I'd like to know if I can use a relative link with change of port.

You can't.

However, if you have access to a server-side language, like PHP, you can
do something like:

<?php
echo '<a href="http://' . $_SERVER['HTTP_HOST']
. ':81/">Link to port 81 on this server</a>';
?>
 
R

rach

Toby A Inkster said:
rach said:
I'd like to know if I can use a relative link with change of port.

You can't.

However, if you have access to a server-side language, like PHP, you can
do something like:

<?php
echo '<a href="http://' . $_SERVER['HTTP_HOST']
. ':81/">Link to port 81 on this server</a>';
?>

--


Thanks Toby. I suspected that it cannot be done. I do have php on that
server, so I will try that 1st thing when I wake up!

Oh and thanks William for your tip. Though in this case I want the transient
nature of my dynamic ip to work in my favor.

Rach
 
T

Toby A Inkster

Leif said:
Toby said:
<?php
echo '<a href="http://' . $_SERVER['HTTP_HOST']
. ':81/">Link to port 81 on this server</a>';
?>

Be careful with that, IE adds port to the Host header IIRC.

Doesn't seem to with IE6/win, but YMMV. Hopefully PHP doesn't trust the
raw HTTP request though.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,438
Messages
2,571,699
Members
48,796
Latest member
Greg L.
Top