no se puede cambiar cualquier parte de la autoridad (es decir, el anfitrión : parte portuaria) en las direcciones URL relativas. Ver el algoritmo descrito en section 5.2.2 de RFC 3986 para ver cómo URLs correspondientes son interpretado. Es importante notar que la autoridad simplemente se copia de la URL base o de la URL que se está resolviendo y la estructura de la autoridad nunca se interpreta. Esto implica que no puede cambiar ninguna de sus partes, incluida la parte del puerto.
Aquí está el algoritmo en pseudo-código copiado de la RFC:
-- The URI reference is parsed into the five URI components
--
(R.scheme, R.authority, R.path, R.query, R.fragment) = parse(R);
-- A non-strict parser may ignore a scheme in the reference
-- if it is identical to the base URI's scheme.
--
if ((not strict) and (R.scheme == Base.scheme)) then
undefine(R.scheme);
endif;
if defined(R.scheme) then
T.scheme = R.scheme;
T.authority = R.authority;
T.path = remove_dot_segments(R.path);
T.query = R.query;
else
if defined(R.authority) then
T.authority = R.authority;
T.path = remove_dot_segments(R.path);
T.query = R.query;
else
if (R.path == "") then
T.path = Base.path;
if defined(R.query) then
T.query = R.query;
else
T.query = Base.query;
endif;
else
if (R.path starts-with "/") then
T.path = remove_dot_segments(R.path);
else
T.path = merge(Base.path, R.path);
T.path = remove_dot_segments(T.path);
endif;
T.query = R.query;
endif;
T.authority = Base.authority;
endif;
T.scheme = Base.scheme;
endif;
T.fragment = R.fragment;
No creo que pueda. El puerto es efectivamente parte del nombre de dominio en este contexto. Al especificar el nombre de dominio sin el puerto (sin usar un enlace relativo), básicamente está suministrando un _different_ dominio. –
Vea también http://stackoverflow.com/q/6016120/60075 –