如何从域重定向到另一个保留路径组件?

giu*_*cal 2 html redirect blogs tumblr

我希望将页面从域(正确的子域)重定向到另一个维护相同路径组件的页面.

我正在使用博客服务,而不是运行服务器; 但我可以编辑我博客的全球负责人.

我已设法使用以下方法重定向到其他网站的主页面:

<meta http-equiv="refresh" content="1; url=http://subdomain-2.domain.com">
<script type="text/javascript">
    window.location.href = "http://subdomain-2.domain.com"
</script>
Run Code Online (Sandbox Code Playgroud)

但我不能够重定向任何的第一个域的页面向相应的第二之一-说http://subdomain-1.example.com/post/lorem-ipsum-123http://subdomain-2.example.com/post/lorem-ipsum-123.

我想知道是否可以抓取当前的URL并通过编辑头部将目标域替换为原始域.

我想我只能使用HTML,JavaScript或PHP.

giu*_*cal 5

使用JavaScript解决如下:

<script type="text/javascript">
    window.location.href = "http://" + "here-your-target-domain" + window.location.pathname
</script>
Run Code Online (Sandbox Code Playgroud)

关键因素是window.location.pathname.在这里,我找到了我需要的东西.