请建议如何进行以下重定向:
www.siteA.com/ 目录 / keep-all-those-urls /→www.siteB.com/directory/keep-all-those-urls/
但同时不重定向其他目录:
www.siteA.com/→www.siteA.com/ (此处无重定向)
答案 0 :(得分:0)
您可以在/directory/.htaccess
文件中使用此代码:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?siteA\.com$ [NC]
RewriteRule ^ www.siteB.com%{REQUEST_URI} [L,NE,R=302]
答案 1 :(得分:0)
function reDirection(){
var currentDomain= location.host; // might be wwww.siteA.com
var currentPath = location.pathname;
var reDirectionUrl = "www.site2.com"; // www.site2.com
var reDirectionUrl = (currentPath != "/")? reDirectionUrl+currentPath : currentDomain;
window.location = "http://"+reDirectionUrl;
}