2011-03-28 22 views
0

比如我当前的URL是如何刷新和删除当前的URL一些查询

http://domain.com/category/health-beauty/?session={%22session_key%22%3A%22df1eca3f79e122bd915651e5-1325102496%22%2C%22uid%22%3A%221325102496%22%2C%22expires%22%3A0%2C%22secret%22%3A%229eb858d1fc7dda2b37be912282a41382%22%2C%22base_domain%22%3A%22domain.com%22%2C%22access_token%22%3A%22193986783965592|df1eca3f79e122bd915651e5-1325102496|nJe_UcyAxMt2i6S40QWBKw6-Rek%22%2C%22sig%22%3A%22a7304578c9e00c14ed8e5825e2c2837b%22} 

session是来自Facebook的到来。

现在我想删除或刷新当前网址是

http://domain.com/category/health-beauty/ 

让我知道。

回答

4

下面将剥离出从网址的查询字符串,并刷新页面

if(window.location.indexOf('?') > -1) { 
    window.location = window.location.substr(0, window.location.indexOf('?')); 
} 

此外,如果你想这样做在PHP

$uri = $_SERVER['REQUEST_URI']; 
if(strpos($uri, '?') !== false) { 
    header('location: '.substr($uri, 0, strpos($uri, '?'))); 
} 
0

你想保持会话变量?如果没有,你可以使用标题功能:

header('http://domain.com/category/health-beauty/'); 
+0

这是静态的重定向方式。 (Ben Rowe)回答对于动态url很有帮助。在他回答每一件事后?将被删除,所以url会根据需要非常干净。 – 2011-03-28 06:38:03

0

你看了看PHP服务器和环境变量?
服务器:http://www.php.net/manual/en/reserved.variables.server.php
环境:http://www.php.net/manual/en/reserved.variables.environment.php

随着你的URL的 “http://domain.com/category/health-beauty/会话= ......” 就应该包含这样的事情:

$_SERVER["SERVER_NAME"]: domain.com 
$_SERVER["SCRIPT_NAME"]: /category/health-beauty/ 
$_SERVER["PHP_SELF"]: /category/health-beauty/ 

$_ENV["SERVER_NAME"]: domain.com 
$_ENV["SCRIPT_NAME"]: /category/health-beauty/ 

如果你想检查所有这些变量和很多更多,把<?php phpinfo(); ?>在您的域的文件并打开它...您将能够找到适合您需要的正确变量!