我想像这样制作自定义WordPress URL:http://example.com/index.php?productID=123
和类别http://example.com/index.php?categoryID=123
,原因是我们有一个用一些旧的自定义CMS编写的网站,我们想将其移动到WordPress,我们不想丢失我们在谷歌中的索引,这里的问题是每当我们在自定义URL重写中包含index.php
时,它都不起作用,它会自动删除index.php
以下是我尝试过的代码:
add_rewrite_rule('index.php?p=(.*)', 'index.php?productId=$matches[1]', 'top');
add_rewrite_rule('index.php?cat=(.*)', 'index.php?categoryId=$matches[1]', 'top');
我也尝试过这个插件,它工作正常,但问题是它将?
转换为 URL 中的%3F
,从而导致 404 错误
根据Google的建议,您应该在.htaccess
文件中使用301重定向。 https://support.google.com/webmasters/answer/93633?hl=en
要添加到.htaccess
的行的示例如下: redirect 301 /index.php?oldProduct=123 /index.php?newProduct=123
但你真的有无限的选择。您可以在 http://www.isitebuild.com/301-redirect.htm