Mass 301已永久移动重定向

时间:2015-05-29 04:00:35

标签: php html .htaccess http-status-code-301

我无法找到将25个以上网页重定向到新网址的最佳方法。我已经将一个weebly站点更新为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 个答案:

答案 0 :(得分:0)

需要做出一些重要的改变:

  1. 请勿将mod_alias规则与mod_rewrite规则混合使用。
  2. 在内部重写规则之前保留重定向规则。
  3. 在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]
    

    清除浏览器缓存后进行测试。