簡體   English   中英

將 Blogger 自定義域帖子重定向到另一個域

[英]Redirect Blogger custom domain posts to another domain

我在http://blog.example.com上有一個博主博客,我已經使用 WordPress 將博客移到了一個新站點,並在 WordPress 內設置了重定向以將博主帖子的 URL 重定向到新 URL,例如:博主上的帖子是: http://blog.example.com/2016/12/google.html : http://blog.example.com/2016/12/google.html新網站上的帖子 URL 是: https://subdomain.domain.com/google/ : https://subdomain.domain.com/google/我在 WordPress 中設置了重定向以從https://subdomain.domain.com/2016/12/google.html重定向https://subdomain.domain.com/2016/12/google.htmlhttps://subdomain.domain.com/google/

所以我想要的只是在舊博主博客中添加一個代碼,將每個頁面重定向到新域中的另一個頁面,例如:

重定向自: http://blog.example.com/2016/12/google.html : 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

提前致謝!

找到標題部分中的標記,並在標記后插入以下代碼: http://www.yoursite.com/'" /> 將“ http://www.yoursite.com ”替換為要訪問的網站的 URL你想重定向你的博客。

來源文章

在您的帖子編輯中從撰寫切換到 HTML,並將此代碼放在帖子正文中。

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

實際上,這是我第一次發布 JavaScript,但我願意接受建議、編輯、評論......

這個想法是將以下腳本放在博客模板中,以便它會自動重定向用戶。

不要忘記更改變量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>

這是一個片段,可以繼續您的解釋。

 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
 <div id=message></div>

將下面代碼中的通用內容替換為您自己的內容后,在博客模板中的“”標簽之后插入下面顯示的代碼。

<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>

來源

暫無
暫無

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

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