大网数据广告活动
网站运营与故障问答

Fastest way to redirect dead URLs to home page

· 52CE 我爱测

A client of mine scrapped his entire wordpress site of many years for a custom CMS. The URL structures both use the /<post_title> format, so a pattern based .htaccess rule is out of the picture for saving the old urls. The old si…

问题原文

原帖链接 · Dan Gayle · CC BY-SA 3.0

A client of mine scrapped his entire wordpress site of many years for a custom CMS. The URL structures both use the /<post_title> format, so a pattern based .htaccess rule is out of the picture for saving the old urls. The old site is effectively dead, but I'd hate to let all of those thousands of backlinks simply die a 404 death.

Is there a faster way than listing each url in a .htaccess directive to redirect 1000s of urls to the home page? (Faster as in load speed, not programming efficiency)

已采纳解答

原帖链接 · MrWhite · CC BY-SA 3.0

In your custom 404 page you could check the structure of the URL and 301-redirect if it looks good - or preferably look it up against a known list of previous Wordpress URLs.

At least this way you are only doing the lookup/redirect if the page doesn't exist.

If you are doing 1000s of redirects with Apache, it will be more efficient/faster to do this in your server config (vhost) files. Ref: Move .htaccess content into vhost, for performance

EDIT: I expect you've considered this already, but the thought was beginning to nag... do these missing pages have equivalent new URLs? Although a lot more work, it will obviously be many(*N) times better (for SEO and users) to redirect to the new URL if possible.

(Where N is a sufficiently large arbitrary number.)

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2013-06-13)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。