我正试图编写RestAPi
服务器代码,我被严重卡住了。
我的目录结构是/var/www/html/RestApi/rest/
文件。我在这个文件夹中编写服务器代码。我的。htaccess文件位于/var/www/html/。以下是my . htaccess的设置。htaccess
file
/var/www/html/<br>
|<br>
|<br>
|--- index.php, .htaccess<br>
|<br>
|---/RestApt/rest/api.php (restapi server code)<br>
/RestApt/rest/ .... (Other files to support api.php)<br>
.htaccess
看起来像
RewriteEngine
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule ^/RestApt/rest/(.*)$ /RestApt/rest/api.php?request=$1 [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^/RestApt/rest/(.*)$ /RestApt/rest/api.php [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} -s
RewriteRule ^/RestApt/rest/(.*)$ /RestApt/rest/api.php [QSA,NC,L]
在我的api。php中,我有一个api:
private function users(){
// Cross validation if the request method is GET else it will return "Not Acceptable" status
if($this->get_request_method() != "GET"){
$this->response('',406);
}
...
}
当我使用chrome的RestApi扩展从浏览器调用RestApi时,我得到以下错误
请求的URL
/RestApi/rest/users
在此服务器上找不到。
在我的apache文件/etc/apache2/apache2.conf
我已经做了以下修改
AllowOverride All
我真的卡住了,请给点光照。
尝试从重写规则中删除第一个斜杠/
。它们应该是这样的:
RewriteRule ^RestApt/rest/(.*)$
我还注意到一个可能的印刷错误:RestApt