I\'ve never seen
The fact that I have never noticed
To decide whether it should be used or not, you should be aware of what it does and whether it's needed. This is already partly outlined in this answer, which I also contributed to. But to make it easier to understand and follow, a second explanation here. First we need to understand:
being used?For some examples, let's assume we have these URLs:
A) http://www.example.com/index.html
B) http://www.example.com/
C) http://www.example.com/page.html
D) http://www.example.com/subdir/page.html
A+B both result in the very same file (index.html
) be sent to the browser, C of course sends page.html
, and D sends /subdir/page.html
.
Let's further assume, both pages contain a set of links:
1) fully qualified absolute links (http://www...
)
2) local absolute links (/some/dir/page.html
)
3) relative links including file names (dir/page.html
), and
4) relative links with "segments" only (#anchor
, ?foo=bar
).
The browser receives the page, and renders the HTML. If it finds some URL, it needs to know where to point it to. That's always clear for Link 1), which is taken as-is. All others depend on the URL of the rendered page:
URL | Link | Result
--------+------+--------------------------
A,B,C,D | 2 | http://www.example.com/some/dir/page.html
A,B,C | 3 | http://www.example.com/dir/page.html
D | 3 | http://www.example.com/subdir/dir/page.html
A | 4 | http://www.example.com/index.html#anchor
B | 4 | http://www.example.com/#anchor
C | 4 | http://www.example.com/page.html#anchor
D | 4 | http://www.example.com/subdir/page.html#anchor
being used?
is supposed to replace the URL as it appears to the browser. So it renders all links as if the user had called up the URL specified in
. Which explains some of the confusion in several of the other answers:
differs from the one being called initially from the user)
:
Say you want to "prettify" some URL using mod_rewrite
:
/some/dir/file.php?lang=en
http://www.example.com/some/dir/file.php?lang=en
http://www.example.com/en/file
Let's assume mod_rewrite
is used to transparently rewrite the user-friendly URL to the real one (no external re-direct, so the "user-friendly" one stays in the browsers address bar, while the real-one is loaded). What to do now?
specified: breaks all relative links (as they would be based on http://www.example.com/en/file
now)
: Better already. But relative links of "type 4" are still broken (except for "case B").
0
讨论(0)