【问题标题】:Redirect Blogger custom domain posts to another domain将 Blogger 自定义域帖子重定向到另一个域
【发布时间】:2017-05-08 15:07:15
【问题描述】:

我在http://blog.example.com 上有一个博主博客,我已使用 WordPress 将博客移至新站点,并在 WordPress 中设置重定向,以将博主帖子 URL 重定向到新 URL,例如: 博主上的帖子是:http://blog.example.com/2016/12/google.html 新网站上的帖子网址是:https://subdomain.domain.com/google/ 我在 WordPress 中设置了重定向,从 https://subdomain.domain.com/2016/12/google.html 重定向到 https://subdomain.domain.com/google/

所以我想要的只是在旧博客中添加一个代码,以将每个页面重定向到新域中的另一个页面,例如:

重定向自:http://blog.example.com/2016/12/google.htmlhttps://subdomain.domain.com/2016/12/google.html

http://blog.example.com/2015/11/yahoo.htmlhttps://subdomain.domain.com/2015/11/yahoo.html

提前致谢!

【问题讨论】:

    标签: wordpress redirect url-redirection blogger


    【解决方案1】:

    在标头部分找到标签,并在标签后插入以下代码:http://www.yoursite.com/'" /> 将“http://www.yoursite.com”替换为您要访问的网站的 URL重定向您的博客。

    Original article

    【讨论】:

    • 感谢您的回复,但这不是我正在寻找的代码将所有页面重定向到新网站主页,我想要一个代码将每个 URL 重定向到另一个具有域的 URL新网站而不是旧网站(每个帖子都发到同一个帖子,但在另一个网站上)
    【解决方案2】:

    在您的帖子编辑中从撰写切换到 HTML,并将此代码放在帖子正文中。

    <script type="text/javascript">
        window.location = 'http://your-external-link';
    </script>
    

    【讨论】:

      【解决方案3】:

      实际上这是我第一次发布 JavaScript,但我愿意接受建议、编辑、cmets ...

      想法是将以下脚本放在博客模板中,以便自动重定向用户。

      不要忘记更改变量googleBaseURLwordpressBaseURL

      <script type="text/javascript">    
          var googleBaseURL = 'http://blog.example.com/', // We define what's our blogger URL
          wordpressBaseURL = 'https://subdomain.domain.com/', // We define what's our wordpress URL
          requestedURL = window.location.href, // We get the URL requested by the user
          requestedPage = requestedURL.split(googleBase)[1], // We get the requested page
          newURL = wordpressBase + requestedPage; // We create our new URL
      
          window.location = newURL; // We redirect
      </script>
      

      这里有一个 sn-ps 可以继续你的解释。

      var div = document.getElementById('message'),
           googleBaseURL = 'http://blog.example.com/', // We define what's our blogger URL
           wordpressBaseURL = 'https://subdomain.domain.com/', // We define what's our wordpress URL
           requested = 'http://blog.example.com/2016/12/google.html', // URL requested by user
           requestedPage = requested.split(googleBaseURL)[1]; // Requested page by user
      
       div.innerHTML = div.innerHTML + "From: " + requested + "<br />"; // Requested url
       div.innerHTML = div.innerHTML + "The script redirect the user to:  " + wordpressBaseURL + requestedPage; // Redirect to this url
      &lt;div id=message&gt;&lt;/div&gt;

      【讨论】:

        【解决方案4】:

        在下面的代码中将通用内容替换为您自己的内容后,在博客模板中的“”标记之后插入下面显示的代码。

        <b:if cond="’data:blog.url" =="“http://your-blog-name.blogspot.com/YEAR/MONTH/BLOG-POST-SLUG.html”‘"><meta content="’0;url=http://yoursite.com/NEW-BLOG-POST-SLUG.html’" http-equiv="’refresh’/"></b:if>
        

        Source

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2023-02-14
          • 1970-01-01
          • 2012-03-14
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多