【问题标题】:URL allows special character in the end. Why?URL 最后允许特殊字符。为什么?
【发布时间】:2019-11-29 23:52:54
【问题描述】:

我的域名最后允许使用特殊字符 (www.testing.com/home/login-)。如何确保不允许这样做并且显示页面不存在,因为正确的 URL 是 www.testing.com/home/login

$routeCustom = new \Zend_Controller_Router_Route(
    '/:controller/:action',
    array(
        'module' => 'website',
        "controller" => "default",
        "action" => "default"
    ),
    array(
        'controller'=>'^[a-zA-Z-_0-9]+', //accept:  a to z , A to Z , - , _ , 0-9 
        'action'=>'^[a-zA-Z-_0-9]+'
    )
);

【问题讨论】:

  • 可能正在进行一些重写或路由
  • @tim 会在 .htaccess 中吗?
  • 许多 url(带有不同的附加)可以指向一个资源。只要您始终选择并发布规范的,这无关紧要。
  • 这真的是通过服务器,检查$_SERVER['REQUEST_URI'];的输出。
  • 是的,这实际上是通过服务器@Progrock

标签: php zend-framework pimcore


【解决方案1】:

是这样的:

$routeCustom = new \Zend_Controller_Router_Route(
    '/:controller/:action',
    array(
        'module' => 'website',
        "controller" => "default",
        "action" => "default"
    ),
    array(
        'controller'=>'^[a-zA-Z-_0-9](.*[a-zA-Z0-9])$', //accept:  a to z , A to Z , - , _ , 0-9 
        'action'=>'^[a-zA-Z-_0-9](.*[a-zA-Z0-9])$'
    )
);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-10
    • 1970-01-01
    相关资源
    最近更新 更多