471,599 Members | 1,158 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,599 software developers and data experts.

How do redirects influence the base URL of an HTML document

How are browsers supposed to calculate the base URL of a resource
after a redirect?
The browser sends a request to

http://www.example.org/dir/index.html

and this results in a redirect to

http://www.example.org/newdir/index.html

the HTML served by index.html contains a CSS reference like this

<link href="styles.css" rel="stylesheet" type="text/css"
media="screen" >

Under which URL is the browser supposed to fetch the stylesheet?
(a) http://www.example.org/dir/styles.css
or
(b) http://www.example.org/newdir/styles.css

Does it make a difference if the redirect is a temporary redirect vs a
permanent redirect?
Thanks a lot for your advice,
Carsten

Nov 6 '07 #1
3 3049
On Tue, 6 Nov 2007, Carsten Leue wrote:
The browser sends a request to
http://www.example.org/dir/index.html
and this results in a redirect to
http://www.example.org/newdir/index.html
Once you have been redirected, the former (old) address has
no effect whatsoever. Everything then refers to
http://www.example.org/newdir/index.html

Btw: You could better write
http://www.example.org/newdir/
without "index.html".
Does it make a difference if the redirect is a temporary redirect
vs a permanent redirect?
No.

--
Bugs in Internet Explorer 7
http://www.unics.uni-hannover.de/nhtcapri/ie7-bugs
Nov 8 '07 #2
On Tue, 06 Nov 2007 21:25:03 +0100, Carsten Leue <ca**********@gmx.net
wrote:
How are browsers supposed to calculate the base URL of a resource
after a redirect?
The browser sends a request to

http://www.example.org/dir/index.html

and this results in a redirect to

http://www.example.org/newdir/index.html

the HTML served by index.html contains a CSS reference like this

<link href="styles.css" rel="stylesheet" type="text/css"
media="screen" >

Under which URL is the browser supposed to fetch the stylesheet?
(a) http://www.example.org/dir/styles.css
or
(b) http://www.example.org/newdir/styles.css
(b), always, unless it's an internal redirect on the webserver and the
browser still thinks it's looking at http://www.example.org/dir/styles.css.
Does it make a difference if the redirect is a temporary redirect vs a
permanent redirect?
No.

If the stylesheet url must stay the same, use this: '
href="/path/to/style.css"'.
--
Rik Wasmus
Nov 9 '07 #3
Carsten Leue:
How are browsers supposed to calculate the base URL of a resource
after a redirect?
Further to the answers given already, here is the relevant RFC
section:

http://www.apps.ietf.org/rfc/rfc3986.html#sec-5.1

--
Jock

Nov 9 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Victor Porton | last post: by
7 posts views Thread by Weston C | last post: by
2 posts views Thread by Blue Streak | last post: by
5 posts views Thread by Advo | last post: by
2 posts views Thread by XIAOLAOHU | last post: by
reply views Thread by Anwar ali | last post: by

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.