2017-08-24 7 views
0

私はPHPで動作しているAPIに取り組んでいます。私は/文字を含むパラメータアドレスにヒットするまで 私は、フォーマットmod_rewriteとエンコードされたパラメータ

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

それが働いたにリクエストを送信します。データベースに保存されたデータを非常に論理的にシフトしました。

だから、私はAPIを呼び出すしようとすると、今、私は404オブジェクトが見つかりません取得Javacript

address = encodeURIComponent(getVal("address")); 

からデータを送信する前にencodeURIComponentでやりました。

これは、ここで符号化されたデータ

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

と私の現在のURLは私の.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 
    ... 
関連する問題