我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

Codeigniter路由正则表达式

I have this:

$route['^[a-zA-Z]{2}$'] = "state";

$route['^[a-zA-Z]{2}$/(:any)'] = "state/city";

And these controllers

state.php

class State extends CI_Controller {

    public function index () 
    {
        echo "OK"; 
    } 
    public function city () 
    {
       echo "Not OK"; 
    } 
}

The first route works perfectly, while the second does not. She should call the city of the State class method but does not call!

url:

http://foo.bar/SP/ ---> OK
http://foo.bar/SP/SANTOS -> 404!

Remove the $ that anchors to the end of the string:

$route['^[a-zA-Z]{2}/(:any)'] = "state/city";

近期文章

  • 如果空帖怎么办?
  • 正则表达式基础 - [^。] [复制]
  • 检查PHP文件是否已损坏
  • PHP包括从下拉选择选项使用jquery AJAX?
  • 将多个变量传递给PHP页面
  • 如何将数组放入SQL?
  • PHP和SQL - 数据库重载
  • 使用php从包含2个指定字母的文本文件中查找单词
  • PHP正则表达式 - 除了字母数字,空格,短划线和@符号之外的所有内容
  • 如果条件不在运算符'相等'上工作并且在赋值运算符上工作
  • 乘以字符串值
  • Paypal和AngellEye Library:您必须只指定一个主接收器和至少一个辅助接收器
  • 目前从图像中删除html链接
  • 执行插入查询时出错
  • HHVM在NotFoundHttpException上中断
  • OpenCart - 如何在点击时重新加载验证码图像?
  • 这个扩展ASCII的一部分是什么编码?
  • PHP脚本完成后删除文件
  • PHP表单SQL格式错误
  • 正则表达式 - 替换存储元素中的空格

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华