简体   繁体   English

WordPress使用htaccess从URL更改或删除自定义帖子

[英]WordPress change or remove custom post slug from url using htaccess

I'm developing a website using wordpress. 我正在使用wordpress开发一个网站。 I have custom post type urls like : 我有以下自定义帖子类型网址:

review/assassins-creed-iii/

But the post type name is review , but I have to rewrite this word to product 但是帖子类型名称是review ,但我必须将此单词改写为product

    product/assassins-creed-iii/

or 要么

    assassins-creed-iii/

It's ok me to remove that slug and show only the post slug 我可以删除该子弹并仅显示帖子子弹

I used this htaccess code : 我用了这个htaccess代码:

RewriteCond %{REQUEST_URI}  (.*)/review/(.*)
RewriteRule .* example.com/%1/product/%2  [QSA,R=301,L]

But this redirects me to 404 page . 但这将我重定向到404 page Anyone know how to change all urls as above? 有人知道如何如上所述更改所有网址吗?

Thank you 谢谢

Please give a try to this 请尝试一下

RewriteRule ^review/(.*)   /products/$1   [L]

This will find "review" and replace it with products. 这将找到“评论”并将其替换为产品。

我使用https://wordpress.org/plugins/custom-permalinks/进行了管理,这使我可以更改任何永久链接

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

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