htaccess 中的 Hash(#) 标签重定向
Hash(#) tag redirect in htaccess
我想将我的旧网站 url 重定向到新网站 url。我在 .htaccess 文件中写了一个重定向规则。但问题是,我的旧 url 在 url 参数之间包含一个哈希标记。
Redirect /de/home/#/de/about/blog/ https://www.example.com/about/blog/
我尝试过的所有方法都会忽略散列标签,并且根本不会重定向。我的旧域具有相同的主机,在重新设计后,urls 发生了一些变化。这就是我想重定向旧 url.
的原因
如果无法使用 htaccess,是否有其他方法可以实现?
或者我可以通过匹配 url 的一部分来使用没有散列的 url 吗?
我的意思是像这样重写;
重定向 /(*)/de/about/blog/ https://www.example.com/about/blog/
你们能帮帮我吗?提前致谢。
片段识别旨在识别文档的部分,它完全由客户端处理,永远不会发送到服务器。
基于它重定向的唯一方法是使用客户端 JavaScript。
您需要在客户端进行重定向:
if (window.location.hash == "#/de/about/blog/") {
window.location = 'http://google.com.ua';
}
无法使用 htaccess。 #
(URL 片段)中的所有内容都不会发送到服务器。唯一的方法是使用 JavaScript,这是许多人 don't like hashbang.
的原因之一
Once you hashbang, you can’t go back. This is probably the stickiest
issue. Ben’s post put forward the point that when pushState is more
widely adopted then we can leave hashbangs behind and return to
traditional URLs. Well, fact is, you can’t. Earlier I stated that URLs
are forever, they get indexed and archived and generally kept around.
To add to that, cool URLs don’t change. We don’t want to disconnect
ourselves from all the valuable links to our content. If you’ve
implemented hashbang URLs at any point then want to change them
without breaking links the only way you can do it is by running some
JavaScript on the root document of your domain. Forever. It’s in no
way temporary, you are stuck with it.
您会在这里找到一些有用的信息:What's the shebang/hashbang (#!) in Facebook and new Twitter URLs for?
我想将我的旧网站 url 重定向到新网站 url。我在 .htaccess 文件中写了一个重定向规则。但问题是,我的旧 url 在 url 参数之间包含一个哈希标记。
Redirect /de/home/#/de/about/blog/ https://www.example.com/about/blog/
我尝试过的所有方法都会忽略散列标签,并且根本不会重定向。我的旧域具有相同的主机,在重新设计后,urls 发生了一些变化。这就是我想重定向旧 url.
的原因如果无法使用 htaccess,是否有其他方法可以实现?
或者我可以通过匹配 url 的一部分来使用没有散列的 url 吗? 我的意思是像这样重写;
重定向 /(*)/de/about/blog/ https://www.example.com/about/blog/
你们能帮帮我吗?提前致谢。
片段识别旨在识别文档的部分,它完全由客户端处理,永远不会发送到服务器。
基于它重定向的唯一方法是使用客户端 JavaScript。
您需要在客户端进行重定向:
if (window.location.hash == "#/de/about/blog/") {
window.location = 'http://google.com.ua';
}
无法使用 htaccess。 #
(URL 片段)中的所有内容都不会发送到服务器。唯一的方法是使用 JavaScript,这是许多人 don't like hashbang.
Once you hashbang, you can’t go back. This is probably the stickiest issue. Ben’s post put forward the point that when pushState is more widely adopted then we can leave hashbangs behind and return to traditional URLs. Well, fact is, you can’t. Earlier I stated that URLs are forever, they get indexed and archived and generally kept around. To add to that, cool URLs don’t change. We don’t want to disconnect ourselves from all the valuable links to our content. If you’ve implemented hashbang URLs at any point then want to change them without breaking links the only way you can do it is by running some JavaScript on the root document of your domain. Forever. It’s in no way temporary, you are stuck with it.
您会在这里找到一些有用的信息:What's the shebang/hashbang (#!) in Facebook and new Twitter URLs for?