简体   繁体   English

重写问题,Wordpress永久链接

[英]Rewrite problems, Wordpress permalink

In one of my sites i'm using wp_online_store plugin for wordpress, this is oscommerce for wordpress. 在我的网站之一中,我正在使用wp_on​​line_store插件来安装wordpress,这是oscommerce用于wordpress。

if i use friendly URL i have inside the links like that: 如果我使用友好的URL,我将在这样的链接中:

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. 其中store是对wordpress(pagename = store)或(page_id = 1)的一页的重写product_info与oscommerce的product_info.php有关。

The main issue is that this kind of link don't exist, wordpress don't recognize it, and sends to: 主要问题是这种链接不存在,wordpress无法识别它,并发送给:

www.mysite.com

So oscommerce rewrites the url but don't recognize it, the correct url are: 因此,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

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, 我需要wordpress将第一个url发送到其中一个,但是要继续响应并使用第一种url,因此必须在内部进行,

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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