.htaccess redirect to page with anchor link
I'm trying to set up a .htaccess file to redirect pages from one domain to another. Works in 99% of cases, the RewriteRules that aren't working are like the one below - if the outbound URL has an #anchor tag, the # symbol is converted into the characters %23 in the browser and then the page does not load at the anchor. Any idea on how to interpret the # tag correctly?
AddType x-mapp-php5 .php
AddHandler x-mapp-php5 .php
Options -MultiViews
Options +FollowSymlinks
RewriteEngine on
RewriteRule bg/row_b1_i_pn1.php http://example.org/s-b-g/b-1#illustration-110
If I cut and paste "http://example.org/s-b-g/b-1#illustration-110" into my browser directly, it loads just fine, but using the RewriteRule, the URL that load开发者_运维知识库s is "http://example.org/s-b-g/b-1%23illustration-110" ... The new site is a drupal site, if that helps any. Thanks.
Try it with the NE flag:
RewriteRule bg/row_b1_i_pn1.php http://example.org/s-b-g/b-1#illustration-110 [NE]
because .htaccess usually interprets # as a comment it kind of defeats proper interpretation .. so instead of using the # in your rewrite rule actually use the %23 code instead. so your rewrite becomes: RewriteRule bg/row_b1_i_pn1.php http://example.org/s-b-g/b-1%23illustration-110 [NE]
more accurately is becomes: RewriteRule bg/row_b1_i_pn1.php http://example.org/s-b-g/b-1/%23illustration-110 [NE]
精彩评论