【问题标题】:Remove Category from the base URL in wordpress从 wordpress 中的基本 URL 中删除类别
【发布时间】:2020-03-16 08:40:00
【问题描述】:

我的帖子 URL 结构是 http://example.com/slug,类别 URL 是 http://example.com/category/category-name

目前,我的自定义结构是 /%postname%/ 并且类别库是空白的。

我想将类别 URL 更改为 http://example.com/category-name。我该怎么办?

我尝试使用 htaccess 但出现 404 错误:

RewriteRule ^category/(.+)$ http://www.yourwebsite.com/$1 [R=301,L]

【问题讨论】:

    标签: regex wordpress mod-rewrite url-rewriting permalinks


    【解决方案1】:

    您收到 404 是因为您将用户从 http://example.com/category/category-name 发送到 http://example.com/category-name,这实际上并不作为页面存在。

    RewriteRule 是重定向,而不是构建 URL。

    从事物的声音来看,您实际上在 Wordpress 中设置了一个类别库(因此在类别名称之前有“类别/”),可以通过转到“设置”->“永久链接”->“删除它类别库”在 Wordpress 面板中。

    如果您也在使用 YoastSEO,您可能希望引用来自 Yoast 的 this documentation

    【讨论】:

      猜你喜欢
      • 2011-08-05
      • 2014-08-17
      • 2013-07-20
      • 1970-01-01
      • 1970-01-01
      • 2011-11-20
      • 2016-09-02
      • 1970-01-01
      • 2016-01-30
      相关资源
      最近更新 更多