我在wordpress中有一个自定义功能,可以打开如下网址: http://example.com/subpage/hello
此: http://example.com/subpage/?var=hello
然后它将在网站上显示“ Hello”。
这是我所拥有的功能:
function redireccion_init()
{
add_rewrite_rule(
'^d1/([^/]*)/?',
'index.php?pagename=d1&titulo=$matches[1]',
'top' );
}
add_action( 'init', 'redireccion_init' );
function redireccion_query_vars( $query_vars )
{
$query_vars[] = 'titulo';
return $query_vars;
}
add_filter( 'query_vars', 'redireccion_query_vars' );
问题是何时“ hello”改为:“ Hello Dolly”。使用http://example.com/subpage/?var=hello小车,它可以工作。但是使用http://example.com/subpage/hello多莉/,它将添加%20,它将在网站中呈现。 (“ Hello%20Dolly”)
我想要的是能够在重定向时将URL中的“ hello-dolly”转换为?var = Hello Dolly。我没有mod_redirect的背景,尝试修改query_vars函数上的var可能是错误的方法?我在这里迷路了。
谢谢!