【问题标题】:How to write web services in Codeigniter?如何在 Codeigniter 中编写 Web 服务?
【发布时间】:2016-10-18 18:37:44
【问题描述】:

我正在使用 Codeigniter 版本 2。在我的项目中,我遵循 HMVC 模式。但现在我想编写 REST api Web 服务。对于 Web 服务,我下载了库 REST_Controller.php。

在我添加库后,按照 HMVC 模式为 wirte webservices 创建一个文件夹。在 webservices 类中创建函数后,我必须以这种格式http://localhost/project_name/index.php/webservices/login 编写 url。

但我不想要这种格式的网址,我想要下面的格式http://localhost/amoeba/webservices/login。请建议我如何在 Codeigniter 中编写 Web 服务。

【问题讨论】:

    标签: php web-services codeigniter codeigniter-2


    【解决方案1】:

    你需要修复你的 .htaccess 文件。

    RewriteEngine on
    RewriteBase /
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond $1 !^(index\.php|images|robots\.txt|css|docs|js|system)
    RewriteRule ^(.*)$ index.php?/$1 [L]
    

    【讨论】:

      猜你喜欢
      • 2013-10-16
      • 1970-01-01
      • 2011-03-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-14
      • 1970-01-01
      • 2023-04-06
      相关资源
      最近更新 更多