How to use # sign as an anchor while url rewriting

2019-07-10 04:09发布

问题:

i have .htaccess that works fine with shorty rewriting rules like

RewriteRule   ^blog/(.+)$   blog_post.php?blogSEOBaslik=$1   [L] 

But there is a page about.php which includes subnavigation via <li><a href="#resume"> named anchor. When i apply a rule like:

RewriteRule   ^about/(.+)$   about.php\#$1  [L]

not behave as usual, standart about.php#resume anchor do. How do i use named anchors in url rewriting rules?

回答1:

Use NE flag for not encoding the resulting URL:

RewriteEngine On
RewriteBase /BAH/

RewriteRule ^about/(.+)$ about.php#$1 [NE,L,R]