繁体   English   中英

如何使用其中的index.php重写wordpress网址

[英]How to rewrite wordpress urls with index.php in them

我想制作如下这样的自定义WordPress URL: http://example.com/index.php?productID=123 : http://example.com/index.php?productID=123以及类别http://example.com/index.php?categoryID=123 ,原因是我们有一个使用某些旧的自定义CMS编写的网站,我们希望将其移至WordPress,并且我们不想丢失google中的索引,这里的问题是,每当我们在自定义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=zh_CN

您要添加到.htaccess中的一行示例如下: redirect 301 /index.php?oldProduct=123 /index.php?newProduct=123

但是您确实有无限的选择。 您可以在http://www.isitebuild.com/301-redirect.htm上看到更多示例

暂无
暂无

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

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