Forum Moderators: phranque
so you cannot perform this type of redirect using Apache/.htaccessWell, you can if you want to redirect all fragments, because then you’re just redirecting the URL itself. It only gets impossible* if some fragments go to URL #1 and others go to URL #2.
Well, you can if you want to redirect all fragments...
I would like to think that no browser is dimwitted enough to try to reappend a fragment identifier...
Redirect /foo /bar#
RewriteRule ^foo$ /bar# [NE,R,L]
However, the browser DOES reappend the fragment identifier (fragid).Oh, ###, does it really? I didn't think to try it out before posting. (Insert “To assume is to make an etcetera” boilerplate here.) Thankfully it's only a problem if the new URL (a) happens to have a fragment with the same id--because if not, the browser just takes you to the top of the page--and (b) that named fragment involves different content than the same-named fragment in the old URL.
RewriteRule ^all-episodes-by-category$ /monthly-archives-of-shows [NE,R,L]Since there's no # in the target you don't need the [NE] flag. Is the URL exactly
I would like to think that no browser is dimwitted enough to try to reappend a fragment identifier (the way you could legitimately do with a query string) when going to an entirely new URL.
Anecdotal evidence suggests that in fact only about one third of Web browsers re-applies the fragment identifier to the redirected URL.But the philosophical speculations are the same then as now:
The former assumes that the document may have changed location, but
that it is still the same document and it still contains the same
fragment. The latter assumes that, because the document changed
location, it probably also changed contents, and doesn't have that
fragment anymore.
you should be surprised to find consistency among browsers when there is no documented agreement on how they should behaveI would be surprised to find consistency among browsers when there IS documented agreement.
So am I reading this right then that I can't redirect this way?
RewriteRule ^all-episodes-by-category$ /monthly-archives-of-shows [NE,R,L]
But it doesn't do anything.