.htaccess redirect with fragment

后端 未结 1 555
时光取名叫无心
时光取名叫无心 2020-12-22 05:33

I need to issue a redirect, using .htaccess, to a URL with a fragment (also known as an anchor), but it\'s automatically escaping the #.

At the moment I want a hard-

相关标签:
1条回答
  • 2020-12-22 05:36

    I think I've got it figured out...

    RewriteCond %{HTTPS} off
    RewriteCond %{REQUEST_URI} /test
    RewriteRule ^test/?(.*)$ $1 [C]
    RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1?%{QUERY_STRING}#MYVALUE [NE,L,R]
    
    RewriteCond %{HTTPS} on
    RewriteCond %{REQUEST_URI} /test
    RewriteRule ^test/?(.*)$ $1 [C]
    RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1?%{QUERY_STRING}#MYVALUE [NE,L,R]
    

    It's a bit poor having to do it once for HTTP and again for HTTPS - I'll see if I can find a way around that.

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