有2000种自定义分类法,称为tax_city 在我的网站中https://www.example.com/tax_city/london
我想将URL更改为如下内容:
https://www.example.com/services/home-care/london
所以,当有人访问这个URL时,实际上可以看到分类法归档页面。但有更好的URL。我知道这在htaccess中是可能的,但不知道从哪一点开始。
有指南吗?
有2000种自定义分类法,称为tax_city 在我的网站中https://www.example.com/tax_city/london
我想将URL更改为如下内容:
https://www.example.com/services/home-care/london
所以,当有人访问这个URL时,实际上可以看到分类法归档页面。但有更好的URL。我知道这在htaccess中是可能的,但不知道从哪一点开始。
有指南吗?
您最好添加或修改rewrite
正在传递给register_taxonomy()
调用自定义分类法。您可以修改重写以符合您的目的。
例如:
$taxonomy_args = array(
// All the variables and their values...
\'rewrite\' => array(
\'slug\' => \'services/home-care\',
),
// ...more variables and values...
);
register_taxonomy( \'tax_city\', $object_types, $taxonomy_args );
在进行更改后,请确保刷新站点的永久链接。这个对我有用。
function custom_rewrite_rules() {
add_rewrite_rule(\'^services/(.*)/(.*)?\', \'index.php?service_category=$matches[1]&tax_city=$matches[2]\', \'top\');
}
add_action(\'init\', \'custom_rewrite_rules\');
我的网站结构是主网站example.com 和两个子文件夹站点/es/ 和/en/example.com 重定向=>;example.com/es/ 和example.com/en/ 是英文版。怎么了?以下内容:example.com/<non-existing-page> 重定向=>;example.com/es/这个主重定向的某些部分导致mysite中的每个不存在的页面。com(此站点为空)被重定向到子域中的主页example.com/es/ 而不是得到404错误。我知道问题出在哪