路径中带有磅字符的Javascript URL重定向 [英] Javascript url-redirection with pound-bang char in path

查看:35
本文介绍了路径中带有磅字符的Javascript URL重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从以下格式重定向我的网址:

How can I redirect my url from the form :

 http://example.com/#!foo

更改为表单:

http://example.com/folder/#!foo

使用javascript吗?

using javascript?

我知道在服务器端不可能使用hashbang进行url重定向,因为#永远不会发送到服务器.

I know that url redirection with hashbang is imposible on server side because # is never sent to the server.

我尝试了以下代码,但未发生重定向.

I have tried the following code but redirection is not happening.

<script>
 window.open("http://example.com/folder/window.location.pathname);

</script>

有什么主意吗?

推荐答案

尝试:

window.location.assign(<the path you want>)

这篇关于路径中带有磅字符的Javascript URL重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆