【发布时间】:2012-05-02 21:31:07
【问题描述】:
我在 example.com 上写了自己的博客。 我正在尝试为我的帖子使用脚注。 所以我在地址上发了一个帖子:
http://www.example.com/blog/2012/04/post-slug
我使用此代码作为脚注(由 markdown-extra 生成):
<p>That's some text with a footnote.<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup></p>
<div class="footnotes">
<hr />
<ol>
<li id="fn:1">
<p>And that's the footnote. <a href="#fnref:1" rev="footnote">↩</a></p>
</li>
</ol>
</div>
此代码作为帖子正文保存在数据库中。
问题是,当我将浏览器指向帖子并单击链接时,它们指向我网站的主页,如下所示:
http://www.example.com/#fnref:1
和
http://www.example.com/#fn:1
而不是正确的:
http://www.example.com/blog/2012/04/post-slug#fnref:1
还有
http://www.example.com/blog/2012/04/post-slug#fn:1
分别。
那是他们不考虑 URL 的部分
/blog/2012/04/post-slug
出于某种原因,他们“认为”他们在主页中。 在 Codeigniter 中,我选择不在 URL 中包含 index.php。当然,我在 routes.php 文件中有一些路由定义。 我无法弄清楚为什么会出现这个问题。也许它与路由有关。 我已经尝试了 config.php 文件中的所有可用选项:
$config['uri_protocol'] = 'AUTO';
(PATH_INFO 等)但没有帮助。
有人可以帮忙吗? 提前致谢。
【问题讨论】:
-
您的
<head>中是否定义了<base href="" />?这将覆盖锚。 -
是的,这就是问题所在。非常感谢你!我想我必须在
和锚点之间做出选择。 -
你可以用一些漂亮的 JavaScript 破解你的方法,但是没有
事情通常会更好。干杯。
标签: php codeigniter hyperlink markdown footnotes