我正在使用 PHP codeigniter 和 chriskacerguis/codeigniter-restserver。
我的目录结构如下
├───cache
├───config
├───controllers <-- api.php
│ └───api
├───core
├───helpers
├───hooks
├───language
│ ├───bulgarian
│ ├───english
│ └───portuguese-brazilian
├───libraries
├───logs
├───models
├───third_party
└───views
└───errors
├───cli
└───html
我的 .htaccess 如下
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
<IfModule mod_headers.c>
Header set Cache-Control "no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires 0
</IfModule>
我编辑了我的 config.php 条目
$config['index_page'] = 'index.php';
在我本地的笔记本电脑上,一切都运行得非常完美。当我将代码移至服务器时,它不起作用。
例如,访问 url 像http://www.example.com/pal/api/class/
-geting 404
同时,如果我在本地执行:http://localhost:88/pal/api/class/
它返回我的输出 JSON
我注意到,在服务器(而不是本地)的日志文件中,url 实际上呈现为http://www.example.com/pal/api/class/index
我假设 url 末尾的 /index 引起了问题。
谁能建议如何解决这个问题?在移动到服务器之前,我扫描并清除了代码中的所有硬线“本地主机”...
**my **routes.php** is as below**
$route['default_controller'] = 'welcome';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;