在我的一个网站中,我使用wordpress的wp_online_store插件,这是wordpress的oscommerce。
如果我使用友好的URL,我有这样的链接:
www.mysite.com/store/product_info/products_id/1234
其中store是一页wordpress(pagename = store)或(page_id = 1)的重写 product_info与oscommerce的product_info.php相关。
主要问题是这种链接不存在,wordpress不认识它,并发送给:
www.mysite.com
所以oscommerce重写了网址,但没有认出来,正确的网址是:
http://www.mysite.com/store?slug=product_info.php&products_id=1234
http://www.mysite.com/index.php?pagename=store&slug=product_info.php&products_id=1234
http://www.mysite.com/index.php?page_id=1&slug=product_info.php&products_id=1309
我需要wordpress将第一个url发送给其中一个,但仍然保持响应并使用第一种url,所以这必须在内部进行,
有些方向会很好,
感谢。
答案 0 :(得分:0)
function add_mypage_var($public_query_vars) {
$public_query_vars[] = 'slug';
$public_query_vars[] = 'cPath';
$public_query_vars[] = 'products_id';
$public_query_vars[] = 'manufacters_id';
$public_query_vars[] = 'sort';
$public_query_vars[] = 'action';
$public_query_vars[] = 'page';
$public_query_vars[] = 'guest';
$public_query_vars[] = 'keywords';
return $public_query_vars;
}
//add a rewrite rules to "Page that links to Store in my case (loja)"
function do_rewrite_mypage() {
add_rewrite_rule('loja/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)?$', 'index.php/loja/?slug=$1.php&$2=$3&$4=$5&$6=$7&$8=$9','top');
add_rewrite_rule('loja/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)?$', 'index.php/loja/?slug=$1.php&$2=$3&$4=$5&$6=$7','top');
add_rewrite_rule('loja/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)?$', 'index.php/loja/?slug=$1.php&$2=$3&$4=$5','top');
add_rewrite_rule('loja/([^/]+)/([^/]+)/([^/]+)?$', 'index.php/loja/?slug=$1.php&$2=$3','top');
add_rewrite_rule('loja/([^/]+)/?$', 'index.php/loja/?slug=$1.php','top');
}
add_filter('query_vars', 'add_mypage_var');
add_action('init', 'do_rewrite_mypage');