-1

Can some one please help me to understand how to do this following PHP's simple redirection in either Javascript or jQuery?

If the client wanted to redirect the www.clientsite.com/bbc to http://www.bbc.com/ then in PHP I would just make the "bbc" folder and create an index.php file in it and add these lines:

<?php
  header("Location: http://www.bbc.com/");
?>

So my question is, how can I redirect www.clientsite.com/bbc to BBC page, or if it's www.clientsite.com/food then to Food Network and so on with either Javascript or jQuery? Thank you very much in advance!

UPDATE:

Thank you everyone for your help! For some reason the window.location.href wasn't redirecting my page, so I ended up using the window.location.replace. And found these pages very helpful:

AlwaysANovice
  • 983
  • 4
  • 15
  • 34

2 Answers2

3

JS redirect with nojs fallback.

Code:

<script>
  window.location.href = "YOUR-URL";
</script>

<noscript>
  <META http-equiv="refresh" content="0;URL=YOUR-URL">
</noscript>
Linus
  • 448
  • 2
  • 5
1

setTimeout(function(){window.location.href='http://wmtest2.nl/portfolio/'},19500);

19500 - is timing, this will redirect to the link after 19.5secs