我已经像这样向 wordpress 添加了一个查询字符串 var ,现在我需要将符号从 ? 斜线,所以这些
http://example.com/myweb/page-1/?param=value
http://example.com/myweb/page-2/?param=value
http://example.com/myweb/page-3/?param2=value
看起来像这样:
http://example.com/myweb/page-1/param/value
http://example.com/myweb/page-2/param/value
http://example.com/myweb/page-3/param2/value
我在 .htaccess 中尝试但没有运气,看到这篇文章解释了它,但我无法使用它,我不擅长正则表达式,这个特定的例子很难调试,所以我很感激一些帮助。
这是我的代码:
function add_rewrite_rules($aRules)
{
$aNewRules = array('page-1/([^/]+)/?$' => 'index.php?pagename=page-1¶m=$matches[1]');
//ALso tried $aNewRules = array('myweb/page-1/([^/]+)/?$' => 'myweb/index.php?pagename=page-1¶m=$matches[1]');
$aRules = $aNewRules + $aRules;
return $aRules;
}
// hook add_rewrite_rules function into rewrite_rules_array
add_filter('rewrite_rules_array', 'add_rewrite_rules');
谢谢