RestApi server code is not workinng

112 views Asked by At

I am trying to write the RestAPi server code and I am badly stuck.

My directory structure is /var/www/html/RestApi/rest/ file. I am writing the sever code in this folder. My .htaccess file is located at /var/www/html/.htaccess and files located Following is setting of my .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 looks like

RewriteEngine On

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]

Now in my api.php I have one 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);
        }
        ...
    }

After having all this when I call RestApi from browser using chrome RestAPi extension i am getting following error

The requested URL /RestApi/rest/users was not found on this server.

In my apache file /etc/apache2/apache2.conf I already did following modification

AllowOverride All

I am really stuck, please throw some light.

1

There are 1 answers

7
umka On BEST ANSWER

Try to remove the very first slash / from your rewrite rules. They should look like this:

RewriteRule ^RestApt/rest/(.*)$

Also I've noted a possible misprint: RestApt