# Remove query w/o replacing URL using wix-location:to(path)

**URL:** <https://forum.wixstudio.com/t/remove-query-w-o-replacing-url-using-wix-location-to-path/29378>\
**Category:** Ask the community\
**Tags:** question, code\
**Created:** [February 22, 2018, 1:25pm UTC](https://forum.wixstudio.com/t/remove-query-w-o-replacing-url-using-wix-location-to-path/29378 "2018-02-22T13:25:44Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![\_doug-1](https://avatars.discourse-cdn.com/v4/letter/_/a587f6/32.png) [@\_doug-1](https://forum.wixstudio.com/u/_doug-1)\
**Post date:** [February 22, 2018, 1:25pm UTC](https://forum.wixstudio.com/t/remove-query-w-o-replacing-url-using-wix-location-to-path/29378/1 "2018-02-22T13:25:44Z")

</div>

When navigating to a new path any query parameters are on the URL are kept. I need to remove them. The only way that seems to work is to replace the whole URL but that causes the page to blank white as a full page reload is done.

Is there a way to navigate to another page w/o the query params of previous page?

---

<div class="post-metadata">

**Author:** ![keawe-wong](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/keawe-wong/32/1943_2.png) [@keawe-wong](https://forum.wixstudio.com/u/keawe-wong)\
**Post date:** [March 22, 2018, 5:51am UTC](https://forum.wixstudio.com/t/remove-query-w-o-replacing-url-using-wix-location-to-path/29378/2 "2018-03-22T05:51:11Z")

</div>

I have the same issue. I can’t find a better solution neither. For now, I have to code to set baseUrl + prefix / path every time when going to any page in order to make sure the query is clear. Very annoying!!

---

<div class="post-metadata">

**Author:** ![\_tal](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/_tal/32/669_2.png) [@\_tal](https://forum.wixstudio.com/u/_tal)\
**Post date:** [March 22, 2018, 1:44pm UTC](https://forum.wixstudio.com/t/remove-query-w-o-replacing-url-using-wix-location-to-path/29378/3 "2018-03-22T13:44:20Z")

</div>

Hi,  
Can you please send us a video of the issue using [screencast](http://www.techsmith.com/download/jing/) ? Simply recreate the issue while recording the steps. Add the [screencast.com](http://screencast.com) URL to your response.

Thank you in advance,  
Tal.

---

<div class="post-metadata">

**Author:** ![keawe-wong](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/keawe-wong/32/1943_2.png) [@keawe-wong](https://forum.wixstudio.com/u/keawe-wong)\
**Post date:** [March 22, 2018, 4:55pm UTC](https://forum.wixstudio.com/t/remove-query-w-o-replacing-url-using-wix-location-to-path/29378/4 "2018-03-22T16:55:29Z")

</div>

Hi Tal,

Here is the screencast. I highlighted the uri query in the video. And then I go to another page. The query will stay if I use wixLocation.to(‘/some-page’). The only way to clear it is to use:

const baseUrl = wixLocation.baseUrl;  
wixLocation.to(`${baseUrl}/some-page`);

But I can’t code the Menu to direct the page. Therefore, the uri parameter cannot be cleared sometimes.

And btw: We do have a paid account. I am just using a free site for development before we go live.

Thanks for looking into this and have a great day!

Keawe

[https://vimeo.com/261341958](https://vimeo.com/261341958)

---

<div class="post-metadata">

**Author:** ![\_doug-1](https://avatars.discourse-cdn.com/v4/letter/_/a587f6/32.png) [@\_doug-1](https://forum.wixstudio.com/u/_doug-1)\
**Post date:** [March 22, 2018, 5:34pm UTC](https://forum.wixstudio.com/t/remove-query-w-o-replacing-url-using-wix-location-to-path/29378/5 "2018-03-22T17:34:03Z")

</div>

@Tal

[![]( " - YouTube") ](https://www.youtube.com/watch?v=rWjY0WLyJzs)

---

<div class="post-metadata">

**Author:** ![pellegrini-gabriel](https://avatars.discourse-cdn.com/v4/letter/p/7bcc69/32.png) [@pellegrini-gabriel](https://forum.wixstudio.com/u/pellegrini-gabriel)\
**Post date:** [March 22, 2018, 6:26pm UTC](https://forum.wixstudio.com/t/remove-query-w-o-replacing-url-using-wix-location-to-path/29378/6 "2018-03-22T18:26:14Z")

</div>

same problem here.

In additional, I have a page that sends an email via sendGrid. Just the first time I click the button sends the email. After that, I have to refresh the page to send another one.

---

<div class="post-metadata">

**Author:** ![pellegrini-gabriel](https://avatars.discourse-cdn.com/v4/letter/p/7bcc69/32.png) [@pellegrini-gabriel](https://forum.wixstudio.com/u/pellegrini-gabriel)\
**Post date:** [March 26, 2018, 1:59pm UTC](https://forum.wixstudio.com/t/remove-query-w-o-replacing-url-using-wix-location-to-path/29378/7 "2018-03-26T13:59:08Z")

</div>

any solution for this trouble?

---

<div class="post-metadata">

**Author:** ![\_tal](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/_tal/32/669_2.png) [@\_tal](https://forum.wixstudio.com/u/_tal)\
**Post date:** [March 27, 2018, 12:47pm UTC](https://forum.wixstudio.com/t/remove-query-w-o-replacing-url-using-wix-location-to-path/29378/8 "2018-03-27T12:47:17Z")

</div>

Hi,  
Thanks for the detailed videos. It seems like a bug. I’ve forwarded it to the relevant department. I’ll keep you posted once it is resolved.

Have a good day,  
Tal.

---

<div class="post-metadata">

**Author:** ![michele-giannone](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/michele-giannone/32/2203_2.png) [@michele-giannone](https://forum.wixstudio.com/u/michele-giannone)\
**Post date:** [March 30, 2018, 10:44am UTC](https://forum.wixstudio.com/t/remove-query-w-o-replacing-url-using-wix-location-to-path/29378/9 "2018-03-30T10:44:58Z")

</div>

Same problem for me.

---

<div class="post-metadata">

**Author:** ![\_tal](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/_tal/32/669_2.png) [@\_tal](https://forum.wixstudio.com/u/_tal)\
**Post date:** [April 10, 2018, 9:22am UTC](https://forum.wixstudio.com/t/remove-query-w-o-replacing-url-using-wix-location-to-path/29378/10 "2018-04-10T09:22:30Z")

</div>

Hi guys,  
Currently, we don’t support removing query params from the URL. I’ve forwarded your feedback to the relevant department and we’ll update you if there’s a change with it.

Have a good day,  
Tal.

---

<div class="post-metadata">

**Author:** ![thrishtilabs](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/thrishtilabs/32/950_2.png) [@thrishtilabs](https://forum.wixstudio.com/u/thrishtilabs)\
**Post date:** [July 11, 2018, 9:48pm UTC](https://forum.wixstudio.com/t/remove-query-w-o-replacing-url-using-wix-location-to-path/29378/11 "2018-07-11T21:48:28Z")

</div>

Hi Tal,  
This is a highly required and logical feature. My website link is getting annoyingly big because of this. The only solution now is to reload the page to remove the query parameter which takes lot of time.

Solution:

Develop a Wix.location.query.remove method.

Thanks.

---

<div class="post-metadata">

**Author:** ![matt42150](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@matt42150](https://forum.wixstudio.com/u/matt42150)\
**Post date:** [May 9, 2019, 3:26pm UTC](https://forum.wixstudio.com/t/remove-query-w-o-replacing-url-using-wix-location-to-path/29378/12 "2019-05-09T15:26:07Z")

</div>

Any updates here? This really is an annoying issue.

---

<div class="post-metadata">

**Author:** ![sedmondsonwork](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/sedmondsonwork/32/10039_2.png) [@sedmondsonwork](https://forum.wixstudio.com/u/sedmondsonwork)\
**Post date:** [August 30, 2019, 12:14am UTC](https://forum.wixstudio.com/t/remove-query-w-o-replacing-url-using-wix-location-to-path/29378/13 "2019-08-30T00:14:38Z")

</div>

Hi,

This is a horrible thing - persisting querystrings between local page links can cause all sorts of unpredictable bugs.

To work around this, I am lucky, because only one of my pages ever gets landed on with a querystring, so this gives me the opportunity to remove the querystring when the user navigates _away_ to another page on my site.

I do this by calling a small check function on my page script onReady(), which checks to see if a querystring needs to be reset, and then reloading THE SAME page again, with blank values for each query parameter - wix is clever enough not to reload the current page again, but it does update the URL with updated querystring values. Looks like this:

```javascript
import wixLocation from 'wix-location';

export function resetQuerystring() {
  let query = wixLocation.query;
  let numQueries = Object.keys(query).length;
  if(numQueries > 0){
    if (query.id|| query.name|| query.loc|| query.dat) {
      let path = wixLocation.path;
      let prefix = wixLocation.prefix;
      console.log("found a query string value... resetting now");
      wixLocation.to("/" + prefix + "/" + path + "?id=&name=&loc=&dat=");
    }
  }
}

```

This forces the query values to be null and when the user navigates one more time, the querystrings are gone.

I realise it won’t work for everyone but maybe it will help.

Another alternative to prevent behaviour resulting from an unwanted/expired querystring would be to add a timestamp your querystrings, and then make a check for a valid timestamp before processing the queries - for example, only queries with a timestamp within the last 10 secs are processed, otherwise they are ignored.

Hope that helps.

A function for clearing querystrings in the wixLocation module would be really helpful, because as we’ve all said, forced sticky querystrings are nasty.
