从htaccess批量301重定向

编程入门 行业动态 更新时间:2024-10-14 02:22:52
本文介绍了从htaccess批量301重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个电子表格,其中包含404错误链接列及其相应的301重定向。

I have spreadsheet which has column of 404 error link and its respective 301 redirects. for e.g)

404 error page 301 redirect www.abc/1.php www.abc/com/2.php .............. ............

该电子表格具有大约1000多个链接。

The spreadsheet has around 1000+ links.

apache config或htaccess中有什么办法可以处理批量301重定向?

Is there any way in apache config or htaccess where can I handle bulk 301 redirects?

推荐答案

批量设置的最佳方法是 RewriteMap 指令在mod-rewrite中。请注意,这不适用于.htaccess文件。您需要在真实的apache配置文件中对其进行编辑(而且好消息是它确实比.htaccess动态配置要快)。

The best way for a Bulk setting is the RewriteMap directive in mod-rewrite. Note that this will not work in a .htaccess file. You'll need to edit it in a real apache configuration file (and the good news is that will be really faster than a .htaccess dynamic configuration).

检查 txt:关键字。

可能是这样的:

RewriteMap myredirects txt:/path/to/my/txt/map.txt RewriteCond ${myredirects:$1} ^/.+ RewriteRule ^(.+)$ %0 [R=302]

当您可以正常使用时,请转换301中的302,然后使用 dbm:关键字(和 httxt2dbm 命令将txt文件转换为更快的哈希图,但这在链接的文档中有解释。)

When you'll get it working well transform the 302 in 301, and convert the txt file to an faster hashmap with the dbm: keyword (and a httxt2dbm command, but that's explained in the linked doc).

更多推荐

从htaccess批量301重定向

本文发布于:2023-10-31 13:43:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1546258.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:批量   重定向   htaccess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!