2017-08-24 110 views
0

我正在使用PHP运行API。 我想在格式mod_rewrite和编码参数

http://localhost/crm/api/addCustomer/John/Doe/Address 123/... 

它的工作请求发送,直到我打包含/字符参数地址。它将逻辑上保存的数据转移到数据库中。

所以我从Javacript

提交数据之前完成encodeURIComponent方法
address = encodeURIComponent(getVal("address")); 

现在,我得到404未找到对象,当我尝试调用API。

这是我当前的URL与编码数据

http://localhost/crm/api/addCustomer/John/Doe/Address%202166%2F62/..... 

,这里是我的.htaccess

Options +FollowSymLinks -MultiViews 
# Turn mod_rewrite on 
RewriteEngine On 
RewriteBase /crm/api 


RewriteRule ^getCustomers apihandler.php?action=getCustomers [NC,L,QSA] 
RewriteRule ^getCustomer/(.*)$ apihandler.php?action=getCustomer&id=$1 [NC,L,QSA] 
RewriteRule ^addCustomer/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+) apihandler.php?action=addCustomer&name=$1&surname=$2&address=$3&country=$4&email=$5&phone=$6 [NC,L,QSA] 

如何解决这一问题?

+0

首先,你不应该使用'GET'要求创造新的纪录。 'GET'用于获取东西,而不是创建它们。改为使用'POST'。 – akond

回答

0

AllowEncodedSlashes Nodecode到您的虚拟主机配置:

所有的
<VirtualHost *:80> 
    ServerName ... 
    DocumentRoot ... 
    AllowEncodedSlashes Nodecode 
    ...