【问题标题】:How to add .html end of URL如何添加 .html 结尾的 URL
【发布时间】:2015-04-11 14:25:24
【问题描述】:

我是 Phalcon PHP 的新手。我不知道如何将 .html 添加到每个页面的 url 末尾。我已经查找了文档。文档中没有与此相关的任何内容

谢谢,

【问题讨论】:

  • 您可以在 Web 服务器的配置中通过一些 URL 重写来执行此操作。真正的问题:你为什么想做这么丑陋的事情?
  • 对于seo,对seo不是更友好吗?
  • 它应该与 SEO 无关。看stackoverflow,没有.html,所有问题都排得很高。
  • 如果您在设计应用程序时首先想到的是 SEO,那么您做错了,感觉比过早优化还要糟糕。专注于创建一个漂亮且可用的应用程序,然后考虑 SEO。
  • 通过 SE 抓取增加 seo 缓存的静态页面内容...参考:doordie.co.in/seo/160216

标签: phalcon phalcon-routing


【解决方案1】:

您可以自定义路由参数,例如:

$router->add(
    "/documentation/{name}.{type:[a-z]+}\.html",
    array(
        "controller" => "documentation",
        "action"     => "show"
    )
);

将/documentation/color.doc.html 路由到带有参数$this->dispatcher->getParam("name") === "color" 和$this->dispatcher->getParam("type") === "doc" 的DocumentationController 中的showAction

更多信息请阅读http://docs.phalconphp.com/en/latest/reference/routing.html中的文档

【讨论】:

    猜你喜欢
    • 2011-01-05
    • 2022-01-25
    • 1970-01-01
    • 1970-01-01
    • 2023-03-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多