简体   繁体   English

如何根据 htaccess 或 wp-config 或 function.php 中的 ID 在 worpress 中重定向动态 URL

[英]how can i redirect dynamic URL in worpress base on ID in htaccess or wp-config or function.php

I want to redirect 301 to the below URL我想将 301 重定向到以下 URL

worpress.com/NewsInfoPrint?id=13624 worpress.com/NewsInfoPrint?id=13624

to

wordpress.com/news/13624/ wordpress.com/news/13624/

// number is ID post in WordPress and I need for all posts to do that, so the number is dynamic // 数字是 WordPress 中的 ID 帖子,我需要所有帖子都这样做,所以数字是动态的

how can I do that?我怎样才能做到这一点?

Please try this one.请试试这个。

RewriteEngine On  
RewriteCond %{REQUEST_URI}  ^\/NewsInfoPrint$ 
RewriteCond %{QUERY_STRING} ^id=([0-9]*) 
RewriteRule ^(.*)$ \/news/%1/? [R=301,L]

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

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