簡體   English   中英

301重定向FOR(而不是)js腳本

[英]301 redirect FOR (and not with) a js script

我必須重定向一個js腳本,我已嘗試在htaccess中使用301定義,但它不起作用。 我到處都找到了如何使用js重定向頁面,而不是如何重定向js。 我有一個系統,用戶必須在調用在線js文件的個人設備上安裝,現在我已經更改了服務器,我必須重定向舊js的所有請求。 謝謝

如果您更改了域名。 在以前的域文檔根目錄中使用此.htaccess文件。

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteBase /

# Redirect JS file 
# If someone enters  http://olddomain.com/old.js in the browser it will be 
# redirected to http://newdomain.com/scripts/script.js file
RewriteRule ^old.js$ http://newdomain.com/scripts/script.js [R=301,L]

# Redirect domain
Options +FollowSymLinks
RewriteCond %{HTTP_HOST} ^olddomain.com [NC]
RewriteRule ^(.*)$ http://newdomain.com/$1 [R=301,L]


</IfModule>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM