简体   繁体   English

htaccess 301在Wordpress中重定向Vs php脚本

[英]htaccess 301 redirect Vs php script in Wordpress

I want to modify all the old URLs to a recently migrated WP site. 我想将所有旧URL修改为最近迁移的WP网站。 The modification logic is a bit complex, so I'm thinking of a using some PHP script to do the conditional regexp_replace in the URL. 修改逻辑有点复杂,因此我正在考虑使用一些PHP脚本在URL中执行条件regexp_replace。

The questions are : 问题是:

  1. Is this a bad strategy compared to htaccess 301 redirect, from SEO and efficiency standpoint? 从SEO和效率的角度来看,与htaccess 301重定向相比,这是一个不好的策略吗?
  2. Where would I add this (regexp replace code) in the index.php of WP? 我将在WP的index.php中将此代码添加到哪里(正则表达式替换代码)?

As long as the old page returns a 301 in the head along with the distinction of where the page lives now it doesn't really matter which way you generate your 301 response. 只要旧页面的头部返回301,以及现在页面所在位置的区别,生成301响应的方式实际上并不重要。

If you just rename all the old pages you will lose all you SEO of those pages. 如果仅重命名所有旧页面,则将丢失所有这些页面的SEO。

Re point 1, it depends on the number of rules. 关于点1,它取决于规则的数量。 Consider that, with an htaccess-based solution, the redirect rules are applied irrespective of whether they're needed or not. 考虑到,在基于htaccess的解决方案中,无论是否需要重定向规则,都将应用它们。

Re point 2, there are redirect plugins for that: 关于第2点,有用于此的重定向插件:

http://www.google.com/search?q=site:wordpress.org/extend/plugins+redirect http://www.google.com/search?q=site:wordpress.org/extend/plugins+redirect

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM