【问题标题】:Codeigniter : a href with hash not working in codeigniterCodeigniter:带有哈希的href在codeigniter中不起作用
【发布时间】:2015-06-30 22:32:25
【问题描述】:

我现在正在开发一个网站,每个页面中都有许多内部链接。该项目在codeigniter中。

在 html 代码的某些部分,我使用锚链接进行内部链接,例如

<a href="http://something.com/products/product_1/features/#quality">Quality</a>

中有一个<div id="quality">Product Quality</div>

http://something.com/products/product_1/features 页面。

但是当我点击这个链接时,什么都不会发生(其他带有正常链接的 href 正在工作)。我在以前的项目中做了同样的过程,但它们是在没有任何框架的 php 中。在codeigniter的href链接中使用hash有什么问题吗?

建议我一些解决方案。任何帮助将不胜感激

【问题讨论】:

  • 如果链接是http://something.com/products/product_1/features#quality怎么办?
  • 代码点火器和锚标签没有问题,试试@chris85 的建议并告诉我们。
  • 如果链接是something.com/products/product_1/features#quality,我假设页面被重定向到功能页面的质量部分(
    一些内容
    )。

标签: php codeigniter href fragment-identifier


【解决方案1】:

您可能需要配置您的路线

CI2http://www.codeigniter.com/userguide2/general/routing.html

CI3http://www.codeigniter.com/user_guide/general/routing.html

$route['products/product_1/features/(:any)'] = 'products/product_1/features/$1';

确保您已允许 hash application/config/config.php

$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-=&?#';

http://www.codeigniter.com/docs

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-05
    • 2018-06-29
    • 2012-04-27
    • 2021-12-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多