How to redirect Javascript file 301?

Source: Internet
Author: User
For example, when I want to access www. domainA. com1.js, I will automatically redirect 301 to www. domainB. com2.js. How to do it? For example, when I want www.domainA.com/1.js to be accessed, I will automatically redirect 301 to www.domainb.com/2.js. How to do it?

Reply content:

For example, when I want www.domainA.com/1.js to be accessed, I will automatically redirect 301 to www.domainb.com/2.js. How to do it?

301 redirection is a response from the server, so it can only be implemented by setting the server or using the script language of the server. ToapacheFor example, you can configure.htaccessFile implementation. The add statement is as follows:

redirect 301 /i.js www.domainB.com/2.js

The implementation of the script languagephpFor example, the Implementation statement is as follows:

header('Location: http://www.domainB.com/', true, 301);exit;

Others, suchjavascriptAndmetaThe redirection of tags should not belong to the permanent page orientation (that is, 301 redirection ).
However, you can usejavascript301 redirection.javascriptStore the page information to be redirectedcookieAnd thenphpReadcookieTo determine whether to perform 301 redirection, but this method is still inseparable from the support of the backend.

Are 301 redirects possible using javascript or jQuery?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.