Search code examples
javascriptjqueryseohttp-status-code-301

Are 301 redirects possible using javascript or jQuery?


I'm running Apache 2.0 and I'm just wondering if it is possible to make a 301 redirect using JavaScript or jQuery.

I have an <a></a> tag with href to a specified location and I'm asked to make a 301 redirect when I click that link.

This is for SEO and I'm trying to find a way to do the 301 redirect to the same page in the link without having to create a new page or create a form/submit.


Solution

  • In short No.

    JavaScript runs entirely on the client side. 301 redirects are supposed to come as a response from the server. Which means you cannot do this without server support.