![](/img/trans.png)
[英]How to remove the query string from the wordpress url using .htaccess rule
[英]How to remove dynamic string from url with htaccess
我刚刚完成了Wordpress网站迁移,发现迁移后所有帖子ID都发生了变化,这对我的SEO不利,因为我在URL上使用了ID。
旧网址示例: http : //www.example.com/news/category/postname-ID.html
新网址示例: http : //www.example.com/news/category/postname.html
如您所见,由于不一样,我不再在URL上使用ID。
因此,我想知道如何使用htaccess将URL从示例1重写为示例2
注意:Id与其动态不同。
谢谢
尝试以下规则:
RewriteEngine On
RewriteRule ^(news/category/.*)\-\d+(\.html) $1$2 [R=301,L,NC]
假设ID
是数字。 如果,例如,这也将失败。 您see-this-post-number-13.html
类似于: see-this-post-number-13.html
或This-is-year-2015.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.