在.htaccess中使用重写规则的POST请求 [英] Using RewriteRule in .htaccess for POST request

查看:535
本文介绍了在.htaccess中使用重写规则的POST请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试一个页面锁定为只接受POST请求。作为一个基于REST API的一部分。我有以下,但它似乎并没有工作。任何帮助将是AP preciated。

 的RewriteCond%{REQUEST_METHOD} POST
重写规则^ API /(CALL1 | call2 | call3)?/ / http://www.example.com/api/rest_services.php?_call=$1 [L]
 

解决方案

我的错误。语法错误的重写规则。应为以下。注意在 $ 不是 /

 重写规则^ API /(CALL1 | call2 | call3)?/ $ http://www.example.com/api/rest_services.php?_call=$1 [L]
 

I am attempting to lock down a page to only accept POST requests. as part of an RESTful API. I have the following, but it doesn't seem to work. Any help would be appreciated.

RewriteCond %{REQUEST_METHOD} POST
RewriteRule ^api/(call1|call2|call3)/?/ http://www.example.com/api/rest_services.php?_call=$1 [L]

解决方案

My mistake. Syntax error on the RewriteRule. Should be the following. Note the $ not /

RewriteRule ^api/(call1|call2|call3)/?$ http://www.example.com/api/rest_services.php?_call=$1 [L]

这篇关于在.htaccess中使用重写规则的POST请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆