簡體   English   中英

質量301移動永久重定向

[英]Mass 301 Moved Permanently redirect

我無法找到將25個以上頁面重定向到其新URL的最佳方法。 我已經將一個脆弱的網站更新為一個PHP網站,因此所有.html鏈接現在都為.php,並且某些文件已完全重命名(由於舊網站沒有移動響應,因此正在更新)。

我已經嘗試了一些.htaccess東西來將.html擴展名更改為.php ,但是在我的共享主機上似乎不起作用。

我可以使用php 301 redirect並將其包含在404 page嗎? 還是會傷害SEO? 擁有404到301的新頁面? 還有另一種方法嗎? 除了使用舊名稱創建HTML頁面並添加元刷新之外? 或使用.htaccess嗎?

我看過很多過多的文章,但他們不是SEO重點,還是與我的專業人士不符,我真的想牢記SEO。

ErrorDocument 404 http://www.sitename.co.nz/404_error.php

RewriteEngine On
RewriteCond %{REQUEST_URI} .html$
RewriteRule ^(.*).html$ /$1.php [R=301,L]

#http://www.inmotionhosting.com/support/website/redirects/setting-up-a-301-permanent-redirect-via-htaccess

Redirect 301 /oldfilea.htm /newfilea.htm
Redirect 301 /oldfileb.htm /newfileb.htm
Redirect 301 /oldfilec.htm /newfilec.htm
Redirect 301 /oldfilee.htm /newfilee.htm
Redirect 301 /oldfiled.htm /newfiled.htm

需要進行幾個重要的更改:

  1. 不要將mod_alias規則與mod_rewrite規則混合使用。
  2. 在內部重寫規則之前保留重定向規則。

在root .htaccess中嘗試以下操作:

ErrorDocument 404 http://www.sitename.co.nz/404_error.php

RewriteEngine On

RewriteRule ^oldfilea\.htm$ /newfilea.htm [L,NC,R=301]
RewriteRule ^oldfileb\.htm$ /newfileb.htm [L,NC,R=301]
RewriteRule ^oldfilec\.htm$ /newfilec.htm [L,NC,R=301]
RewriteRule ^oldfilee\.htm$ /newfilee.htm [L,NC,R=301]
RewriteRule ^oldfiled\.htm$ /newfiled.htm [L,NC,R=301]

RewriteRule ^(.+?)\.html$ /$1.php [R=301,L,NC]

清除瀏覽器緩存后進行測試。

暫無
暫無

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

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