我的树莓派网络服务器上未找到该页面

我的树莓派网络服务器上未找到该页面

几周前我写了一个简单的 rest api,这个 api 在我的 web 服务器(bitnami - localhost)和我的付费托管中运行良好。现在我用树莓派设置了一个 web 服务器,我是一个 linux 新手,我买了一个树莓派用于学习。无论如何,web 服务器运行正常,但是当我上传我的 rest api 时,我得到了:

The request Url /project/api/v1/user/getUsers was not found on this server
Apache/2.4.10 (Raspbian) Server at webserver Port 80

通过这种方式我执行请求:

http://webserver/project/api/v1/user/getUsers

现在这个 api 会从 index.php 中分流请求,通过路由器加载正确的 php 文件,在本例中为 user.php -> getUsers (函数)

此角色在 .htaccess 中可用,其内容如下:

RewriteEngine On

#basic roles

RewriteBase /api/v1/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

#Shunk request on index.php 

RewriteRule ^(.+)$ index.php?uri=$1 [QSA,L]

现在我猜测我的网络服务器对此 .htaccess 存在问题,因为如果我输入此 url:

http://webserver/project/api/v1/

我可以正确看到 index.php 响应:

无效的请求

来自我自己的 rest api

对此有什么想法吗?谢谢。

更新

看来.htaccess 读取正确,但找不到index.php 页面,奇怪。

答案1

首先RewriteBase的内容应该是:

RewriteBase /project/api/v1/

我还建议您检查当前的 DocumentRoot 设置,看看它是否指向您的 www 文件夹。

您可以进一步查看以下链接作为参考: http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritebase

相关内容