Wordpress 添加重写规则重定向而不是 "cloaking"
Wordpress add rewrite rule redirecting instead of "cloaking"
我制作了一个 wordpress "add_rewrite_rule" 以干净的方式访问 2 个 GET 变量。
但到目前为止,它只是重定向而不是 "cloaking",它还丢失了 GET 变量。 (本站使用polylang作为插件)
我尝试包括 add_rewrit_rule,将值添加为 "tags",...
function activateresetrule() {
add_rewrite_rule(
'^reset/([^/]*)/([^/]*)/?$',
'index.php?page_id=1330&email=$matches[1]&uuid=$matches[2]',
'top'
);
add_rewrite_rule(
'^activate/([^/]*)/([^/]*)/?$',
'index.php??page_id=1325&email=$matches[1]&uuid=$matches[2]',
'top'
);
//delete when fixed
global $wp_rewrite;
$wp_rewrite->flush_rules(false);
}
add_action( 'init', 'activateresetrule' );
add_filter( 'query_vars', 'activateresetrule_filter' );
function activateresetrule_filter( $query_vars ){
$query_vars[] = 'email';
$query_vars[] = 'uuid';
return $query_vars;
}
目标:https://www.site.be/reset/dfsdf/ddfsfds/
应该是一样的
https://www.site.be/reset&email=dfsdf&uuid=ddfsfds
当前重定向:/dashboard/password-reset-mail/(无 GET 变量)(这是 page_id1330)
谢谢
找到解决方案:
现有的 WP 页:/dashboard/password-reset-mail/?email=info@maximdegroote.be&uuid=96819e7d-c124-4610-9ae9-62ddb4adf678
新的URL:/reset/info@maximdegroote.be/96819e7d-c124-4610-9ae9-62ddb4adf678/
functions.php
function rewriteurl() {
global
$wp,$wp_rewrite;
$wp->add_query_var('email');
$wp->add_query_var('uuid');
$wp_rewrite->add_rule('^reset/([^/]*)/([^/]*)/?$', 'index.php?post_type=dashboard&page_id=1330&email=$matches[1]&uuid=$matches[2]', 'top');
// Reset permalinks, delete after programming
$wp_rewrite->flush_rules(false);
}
thepage.php
$email = $wp->query_vars['email']; echo $email;
$uuid = $wp->query_vars['uuid']; echo $uuid; ?>
我制作了一个 wordpress "add_rewrite_rule" 以干净的方式访问 2 个 GET 变量。
但到目前为止,它只是重定向而不是 "cloaking",它还丢失了 GET 变量。 (本站使用polylang作为插件)
我尝试包括 add_rewrit_rule,将值添加为 "tags",...
function activateresetrule() {
add_rewrite_rule(
'^reset/([^/]*)/([^/]*)/?$',
'index.php?page_id=1330&email=$matches[1]&uuid=$matches[2]',
'top'
);
add_rewrite_rule(
'^activate/([^/]*)/([^/]*)/?$',
'index.php??page_id=1325&email=$matches[1]&uuid=$matches[2]',
'top'
);
//delete when fixed
global $wp_rewrite;
$wp_rewrite->flush_rules(false);
}
add_action( 'init', 'activateresetrule' );
add_filter( 'query_vars', 'activateresetrule_filter' );
function activateresetrule_filter( $query_vars ){
$query_vars[] = 'email';
$query_vars[] = 'uuid';
return $query_vars;
}
目标:https://www.site.be/reset/dfsdf/ddfsfds/ 应该是一样的 https://www.site.be/reset&email=dfsdf&uuid=ddfsfds
当前重定向:/dashboard/password-reset-mail/(无 GET 变量)(这是 page_id1330)
谢谢
找到解决方案:
现有的 WP 页:/dashboard/password-reset-mail/?email=info@maximdegroote.be&uuid=96819e7d-c124-4610-9ae9-62ddb4adf678
新的URL:/reset/info@maximdegroote.be/96819e7d-c124-4610-9ae9-62ddb4adf678/
functions.php
function rewriteurl() {
global
$wp,$wp_rewrite;
$wp->add_query_var('email');
$wp->add_query_var('uuid');
$wp_rewrite->add_rule('^reset/([^/]*)/([^/]*)/?$', 'index.php?post_type=dashboard&page_id=1330&email=$matches[1]&uuid=$matches[2]', 'top');
// Reset permalinks, delete after programming
$wp_rewrite->flush_rules(false);
}
thepage.php
$email = $wp->query_vars['email']; echo $email;
$uuid = $wp->query_vars['uuid']; echo $uuid; ?>