Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress 我可以将带有查询参数的存档页面URL更改为带有斜杠的URL吗_Wordpress_.htaccess_Mod Rewrite_Url Rewriting - Fatal编程技术网

Wordpress 我可以将带有查询参数的存档页面URL更改为带有斜杠的URL吗

Wordpress 我可以将带有查询参数的存档页面URL更改为带有斜杠的URL吗,wordpress,.htaccess,mod-rewrite,url-rewriting,Wordpress,.htaccess,Mod Rewrite,Url Rewriting,我想更改wordpress网站中自定义分类法归档页面的URL 现在,我使用查询字符串来构建每个分类法归档页面 example.com/customeposttype/?genre=bbq 如果用户请求上述URL,将显示bbq的分类归档 现在我想强制URL如下所示 example.com/customeposttype/genre/bbq/ 页面内容应与中的内容相同 “example.com/customeposttype/?流派=烧烤” 是否可以使用add\u rewrite\u rule()或

我想更改wordpress网站中自定义分类法归档页面的URL

现在,我使用查询字符串来构建每个分类法归档页面

example.com/customeposttype/?genre=bbq

如果用户请求上述URL,将显示bbq的分类归档

现在我想强制URL如下所示

example.com/customeposttype/genre/bbq/

页面内容应与中的内容相同

“example.com/customeposttype/?流派=烧烤”

是否可以使用
add\u rewrite\u rule()
或向
.htaccess
添加一些代码来重写URL

我尝试了下面的代码,但没有成功

function my_custom_rewrite() {

  add_rewrite_rule(
    '^/shop/(\w+)/?',
    'index.php/shop/?genre=$matches[1]',
    'top'
  );
}
add_action('init', 'my_custom_rewrite');

尝试使用Wp admin permalink设置您可以尝试使用自定义permalink:

喜欢:/shop/%genre%