更改 osclass 中的 url

问题描述 投票:0回答:1

我想更改 osclass 上的 url 并将

,
替换为
-
现在网址就像:
127.0.0.1/en/search/region,9354963/category,books-magazines
,我想将网址转换为
127.0.0.1/en/search/region-9354963/category-books-magazines

我确实尝试更改

init()
中的
classes/Rewrite.php
并添加代码:

$modified_params = array();
for ($p = 1; $p < count($route_match); $p++) {
    $param_value = str_replace(',', '-', $route_match[$p]);
    $modified_params[] = $param_value;
}

// Set the modified parameters to Params
for ($p = 0; $p < count($modified_params); $p++) {
    if (isset($args[1][$p])) {
        Params::setParam($args[1][$p], $modified_params[$p]);
    } else {
        Params::setParam('route_param_' . ($p + 1), $modified_params[$p]);
    }
}

但还是没有运气

php url-rewriting osclass
1个回答
0
投票

您不能将 , 替换为 -,因为无法区分 slug 中的 - 以及参数和值的分隔符。

示例:/地区-阿拉巴马州/城市-不莱梅

无法识别这是类别结构还是搜索url结构。 据我所知,逗号是seo友好的字符,没有必要改变它,但如果你真的想这样做,仅仅改变这一块是不够的。 尽管如此,您仍然需要使用不同的字符,例如点。

© www.soinside.com 2019 - 2024. All rights reserved.