Add parameter to all my internal Urls

Asked

Viewed 28 times

0

Like, my site has several posts and such, I would like all links of my own site to be with ? ref=app at the end.. even if I changed the page he kept the parameter.

Is there a code? a way to do this ?

  • Research this related to htaccess, it might help you

  • Could you be more objective in the question? Clarify some points of how you are doing?

  • Like, my site I want to open inside an App, and I want when it opens inside an app to have all the url of it with the ref=app, so I’ll know that and by the app and edit the theme as I want so pro app

1 answer

1


You can use rum script to capture your URL and edit it for the new reference.

<script type="text/javascript">
  // PROTETOR DE LINK
  (() => {
  const urlsBases = ["seusite.com", "localhost"];

  for (let urlBase of urlsBases) {

    const anchors = document.querySelectorAll("a[href*='" + urlBase + "']");

    anchors.forEach(el => {
        let urlProtegida = el.getAttribute("href") + "?ref=app"

        el.setAttribute("href", urlProtegida)

        console.log(urlProtegida)
    });
  }
  })();
  </script>

That is, he took his main domain and added the reference: ? ref=app at the end.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.