How do I remove certain parameter and its value from url?

```
<?php $url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; ?>

```

My urls can be `pagename?page=2` or `pagename?param=235235&page=2` or `pagename?page=10&param=5431` or etc. 

I need remove `page=x` from url.