Redirect URL with hash using .htaccess file

前端 未结 3 935
傲寒
傲寒 2020-12-15 08:29

I\'m trying to redirect a url containing an hash to another url.

Example: example.com/#test should redirect to example.com/teste_page

Can this be done using

相关标签:
3条回答
  • 2020-12-15 09:03

    This cannot be done with .htaccess - as far as the browser is concerned, the # and anything following it does not need to be sent to the server, as it's a link for the browser to resolve.

    Here's a related question, as well as an example:

    Note google thinks the request was: http://www.google.com/thisisa404?query=string#fragment

    0 讨论(0)
  • 2020-12-15 09:04

    No, hashes are never sent to the server, they are in-page fragment identifiers, so only used by the browser. So you're .htaccess would never have access to the hash. You'd have to do some nifty redirects to get that info to your server.

    Here are some ideas that might spark something:

    http://forum.modrewrite.com/viewtopic.php?t=3912

    0 讨论(0)
  • 2020-12-15 09:06

    Yes it can be done, just use the No Escape flag... [NE,R,L]

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