SO网友:Stephen S.
First Assumption: That an extra slash was being added for some reason
要查看发生了什么,我想查看阵列中发生了什么。当我
print_r()
我得到的阵列如下:
Array (
[10] => stdClass Object (
[term_id] => 10
[name] => Mozilla
[slug] => mozilla
[term_group] => 0
[term_taxonomy_id] => 11
[taxonomy] => company
[description] =>
[parent] => 504
[count] => 8
[object_id] => 37085
[filter] => raw
)
)
直到我注意到
[parent] => 504
值,我知道当术语从类别分类法转移到公司分类法时,它被转移了(当时我认为这无关紧要)。
这些新知识帮助我得出了一个新的假设。
Second & Correct Assumption: That there was something missing between the two slashes.
我的新想法是url中缺少不存在的父项,而不是将第二个斜杠视为额外的:
前面:示例。com/category/company/mozilla之后:示例。com/company/(缺少父项)/mozilla为了测试这是否是问题所在,我更改了数据库值[parent] => 504
到[parent] => 0
要删除任何父关联并按预期工作以创建正确的url,请执行以下操作:
http://example.com/company/mozilla