【发布时间】:2015-06-02 14:10:37
【问题描述】:
我正在尝试在我的 Apache 2.4 服务器(在 Ubuntu 上)上的 VirtualHost 上创建一个 RESTful API。我有一个名为 dbManager.php 的 php 文件,我正在使用 RewriteRule 使其看起来像一个 api 目录。除了返回 403 错误的 PUT 和 DELETE 命令外,它运行良好。这是我的 conf 文件的编辑版本:
<VirtualHost *>
ServerAdmin onigame@gmail.com
ServerName servername.com
ServerAlias *.servername.com
DirectoryIndex index.html index.php
DocumentRoot /path/to/local/dir/
<Directory />
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
<Limit PUT DELETE>
Require all granted
</Limit>
</Directory>
# RESTful services provided for the fake "api" directory
RewriteEngine on
RewriteRule ^/api/(.*)$ /dbManager.php/$1 [L]
ServerSignature On
AddDefaultCharset utf-8
</VirtualHost>
好吧,PUT 和 DELETE 仍然不起作用并返回 403。我还担心我真的不想在目录上的任何地方都允许 PUT 和 DELETE,而只能通过虚拟的 api 目录。这样做的正确方法是什么?
【问题讨论】:
标签: php apache rest http mod-rewrite