0

在我的一个网站中,我正在使用 wp_on​​line_store 插件 for wordpress,这是 oscommerce for wordpress。

如果我使用友好的 URL,我在这样的链接内有:

www.mysite.com/store/product_info/products_id/1234

其中store是wordpress的一页(pagename=store)或(page_id=1)的rewrite,product_info与oscommerce的product_info.php有关。

主要问题是这种链接不存在,wordpress 无法识别它,并发送到:

www.mysite.com

所以 oscommerce 重写了 url 但不识别它,正确的 url 是:

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,所以这必须在内部进行,

有些方向会很好,

谢谢。

4

1 回答 1

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');
于 2012-05-22T22:11:34.480 回答