简体   繁体   English

导航后如何获取页面上的条目URL?

[英]how to get the entry url on the page, after navigation?

I have the following scenario: 我有以下情况:

I want to pass a parameter to a page foo.com?bar=x , but foo.com automatically redirects based on language to foo.com/en and I am loosing the bar parameter. 我想将参数传递给页面foo.com?bar=x ,但是foo.com根据语言自动重定向到foo.com/en ,我失去了bar参数。

I don't mind I'm in foo.com/en , I just want the bar parameter. 我不在乎我在foo.com/en ,我只想要bar参数。

The Referer solution does not work, as it automatically redirects, and it's the one before foo.com?bar=x . Referer解决方案不起作用,因为它会自动重定向,并且是foo.com?bar=x之前的foo.com?bar=x

Is there a JavaScript or jQuery solution to this problem? 是否有JavaScript或jQuery解决此问题的方法?

edit 编辑

I just have a script on the page, foo.com is not my domain, I have the script on both foo.com and foo.com/en . 我在页面上只有一个脚本, foo.com不是我的域名,我在foo.comfoo.com/en上都有该脚本。 The problem is that on foo.com the script does not get called, and on foo.com/en I don't have the parameters any more. 问题是在foo.com上脚本没有被调用,而在foo.com/en我不再有参数。

The page foo.com redirects by this method: <meta http-equiv="Refresh" content="0;URL=foo.com/en" /> 页面foo.com通过这种方法重定向: <meta http-equiv="Refresh" content="0;URL=foo.com/en" />

I can't modify this method, and I don't want to, as the solution would not be generic. 我不能修改此方法,也不想修改,因为解决方案不是通用的。

No, there isn't. 不,没有。

If foo.com?bar=x and foo.com? 如果foo.com?bar=x和foo.com? bar=y should have different content, then they shouldn't redirect to the same resource. bar = y应该具有不同的内容,那么它们不应重定向到相同的资源。

您是否尝试过更改重定向,以使其在域名后包含任何内容,例如脚本名称,查询字符串等,在重定向中?

Found the solution, it was much easier, just change from 找到了解决方案,它变得容易得多,只需从

foo.com?bar=x

to

foo.com#bar=x

This way, the hash tag remains, so I have foo.com/en#bar=x 这样,哈希标记仍然存在,所以我有foo.com/en#bar=x

Thank you for your answers. 谢谢您的回答。

You could use a PHP catch... If you have 您可以使用PHP catch ...如果您有

foo.com?bar=x

and you want to redirect to 而您想重定向到

foo.com/en?bar=x

use this 用这个

<meta http-equiv="Refresh" content="0;URL=foo.com/en?bar=<?php echo $_GET["bar"]; ?>" />

the resulting redirect will be 结果重定向将是

foo.com/en?bar=x

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM