I wanted to set automatic links with tags and I wonder how to make it happen so I don’t have to write every case for the site.
I have Polish and English versions of the same site, but I have a problem with the web address.
For example I have sites like this:
https://example.com/tech/privacy-policy – Polish one
and
https://example.com/tech/en/privacy-policy – English one
How to make it to separate the web address into string and if it is on the Polish site to embed “en” between tech/…/privacy-policy, and how to delete it when I’m on English one?
I know that $_SERVER[‘REQUEST_URI’]; shows me web address in PHP but I don’t know how manipulate it in this certain way.
Is it possible to search for “/tech/” for futher web adresses like https:/example.com/tech/en/privacy-policy/something to search for this word and delete “en” if it’s English site redirecting to Polish one and add one if it’s the opposite side?
2
Answers
You can use
includes
method of Javascript:Test Cases:
Here’s a way to do it using javascript: