我很难找到将25+页面重定向到它们的新URL的最佳方法。我已经更新了一个weebly网站到一个PHP一个,所以所有的.html链接现在是.php和一些文件被完全重命名(更新,因为旧的网站没有移动响应)。
我尝试了一些.htaccess的东西,将.html扩展改成了.php扩展,但它似乎在我的共享主机上不起作用。
有没有可以在404 page上使用和包含的php 301 redirect?还是会伤害搜索引擎优化?从404到301到新的页面?还有别的办法吗?除了使用旧名称创建HTML页面并添加meta刷新之外?或者使用.htaccess
我已经看了很多堆栈,但他们没有搜索引擎优化的重点或不符合我的专业,我真的想把搜索引擎优化放在心上。
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发布于 2015-05-31 15:49:42
需要做几个重要的改变:
mod_alias规则与mod_rewrite规则混在一起。在根.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]请在清除浏览器缓存后对其进行测试。
https://stackoverflow.com/questions/30520908
复制相似问题