使用.htaccess文件与哈希重定向URL重定向、文件、htaccess、URL

2023-09-02 00:34:13 作者:忘不掉的伤丶

我想重定向包含哈希到另一个网址的URL。

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

例:example.com/#test应该重定向到example.com/teste_page~~V

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

可以这样使用htaccess的文件来完成?

Can this be done using htaccess file ?

推荐答案

没有,哈希值永远不会发送到服务器,它们在页面片段标识符,所以只能使用浏览器。所以,你的.htaccess永远不会有机会获得哈希值。你必须做一些漂亮的重定向来获取信息到服务器。

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