It should work like that
<button onclick="myFunction()">navigate</button>
<script>
function myFunction()
{
var url = document.URL;
if (window.location.href.indexOf('brand') > -1)
{
alert('yes');
}
url = url.replace('.html','.php')
window.location.href = url;
}
</script>
solved How do i check if my string contains certain words