Make the "Href Prefix" setting apply to search result URLs

We are using a reverse proxy to show our webflow project, blog.toneden.io, at toneden.io/blog. In our Webflow settings, we set the "Href Prefix" setting to "/blog" so that all of our internal links point to the correct URLs (for example, https://www.toneden.io/blog/posts/three-ways-to-win-big-at-facebook-marketing instead of just https://www.toneden.io/posts/three-ways-to-win-big-at-facebook-marketing). This has worked for all internal links, but it doesn't work for the search result URLs generated by the search feature. When we enter a search query, the URL generated is https://www.toneden.io/search?query=<query> instead of https://www.toneden.io/blog/search?query=<query>. This results in a 404 and makes the search feature unusable.


Admin Note:

Workaround provided by Michael Greenwald is to add in a custom script on the search page:
<script>

var forms = document.querySelectorAll('.search-results-form');


for (var i = 0; i < forms.length; i++) {

if (forms[i].getAttribute('action')) {

forms[i].setAttribute('action', '/learn/search')

}

}

</script>

  • Tim Thimmaiah
  • Apr 3 2019
  • Reviewed
  • Michael Greenwald commented
    May 20, 2020 07:15

    I was having this same issue but I ended up solving it with custom javascript. Create a custom code element on the search page and include this.

    <script>

    var forms = document.querySelectorAll('.search-results-form');

    for (var i = 0; i < forms.length; i++) {

    if (forms[i].getAttribute('action')) {

    forms[i].setAttribute('action', '/learn/search')

    }

    }

    </script>

  • +3