mod_rewrite keeps anchor link

后端 未结 1 361
日久生厌
日久生厌 2021-01-16 18:30

I want example.com/site/about#whoami to be redirected to example.com/site/?page=about#whoami using mod_rewrite directives, but I have no idea on ho

相关标签:
1条回答
  • 2021-01-16 19:09

    NOTE: Anchor character # may be passed, but it has no effect on the substitution URL unless the redirection is to a page where the anchor exists. Although Apache cannot do the scrolling of the window down to the anchor, the browser will do it in that case. Here is some Apache information about redirecting anchors

    You may try something like this:

    Options +FollowSymLinks
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^site/(.*)/?   site?page=$1  [NC,NE,L]
    

    Maps

    http://example.com/site/anything

    To

    http://example.com/site/?page=anything

    String site is assumed to be fixed.

    String anything may contain an anchor # and it will be passed in the substitution URL.

    0 讨论(0)
提交回复
热议问题