开发者

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

开发者 https://www.devze.com 2023-02-22 09:04 出处:网络
I have the following scenario: I want to pass a parameter to a pagefoo.com?bar=x, but foo.com automatically redirects based on language to foo.com/en and I am loosing the bar parameter.

I have the following scenario:

I want to pass a parameter to a pagefoo.com?bar=x, but foo.com automatically redirects based on language to foo.com/en and I am loosing the bar parameter.

I don't mind I'm in foo.com/en, I just want the bar parameter.

The Referer solution does 开发者_如何学运维not work, as it automatically redirects, and it's the one before foo.com?bar=x.

Is there a JavaScript or jQuery solution to this problem?

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. 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.

The page foo.com redirects by this method: <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?bar=y should have different content, then they shouldn't redirect to the same resource.


Have you tried changing the redirect so that it includes anything after the domain name e.g. the script name, querystring, etc. in the redirect?


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

Thank you for your answers.


You could use a PHP catch... If you have

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

0

精彩评论

暂无评论...
验证码 换一张
取 消