2012-05-15 83 views
0

在我的網站之一,我使用WordPress的wp_on​​line_store插件,這是wordpress的osCommerce。重寫問題,WordPress的永久

如果我使用友好的URL我有這樣的鏈接裏:

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

哪裏店的WordPress(頁面名稱=店)的一個頁的重寫或(PAGE_ID = 1) 產品的詳細信息是有關oscommerce的product_info.php。

的主要問題是,這種鏈接不存在,WordPress的不承認它,併發送至:

www.mysite.com 

所以自從重寫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的,因此必須進行內部,

有些迪反應會很好,

謝謝。

回答

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