Reputation: 29
I am porting a lot of content from flat file site to Wordpress and have my .htaccess redirect for each page as follows:
redirect 301 /01-chapter1.html http://www.mydomain.com/section1/chapter-1/
Within this content there are a number of anchor links defined as follows:
<a name="106">Link 106</a>
My question is, will the redirect above also handle these anchor links so that old page anchor:
http://www.mydomain.com/01-chapter1.html#106
gets redirected to new page anchor:
http://www.mydomain.com/section1/chapter-1/#106
Hope it does and that I do not have to implement separate redirects for thousands of anchors :(
Many thanks in advance for your advice.
ANSWER
Well I implemented the original redirect I posted:
redirect 301 /01-chapter1.html http://www.mydomain.com/section1/chapter-1/
Tested this FF/IE/Chrome and for whatever reason the redirect seems to be behaving exactly as I hoped without any additional parameters.
external links to:
http://www.mydomain.com/01-chapter1.html#106
are redirecting perfectly to the in page anchor links:
http://www.mydomain.com/section-1/chapter-1/#106
Thanks for the good advice anyway but so far so good!
Upvotes: 0
Views: 3543
Reputation: 10717
Sadly, it does not do that. Check out this blog post: http://www.mikeduncan.com/named-anchors-are-not-sent/
You can try to redirect client-side with JavaScript instead.
edit: More information:
The 301 Redirect Cheatsheet shows many redirection options. When combined with the information gleaned from Can you write a 301 redirect to an anchor point?, means that we can write something like:
RewriteRule ^01-chapter1.html(#.+)?$ /section1/chapter-1/$1 [R=301,NE]
Not really sure of the regex syntax though, might need something else.
Upvotes: 0