简体   繁体   中英

Rewrite problems, Wordpress permalink

In one of my sites i'm using wp_online_store plugin for wordpress, this is oscommerce for wordpress.

if i use friendly URL i have inside the links like that:

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

Where store is the rewrite of one page of wordpress (pagename=store) or (page_id=1) product_info is related to product_info.php of oscommerce.

The main issue is that this kind of link don't exist, wordpress don't recognize it, and sends to:

www.mysite.com

So oscommerce rewrites the url but don't recognize it, the correct url are:

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

I need that wordpress sends the first url to one of these, but keeps responding and using the first kind of url, so this must be made internally,

Some directions would be nice,

Thanks.

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');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM