Why the url request cannot be found in server?

May 18, 2017 479 views
API Apache Ubuntu 16.04

I done creating my own API,and host it to Ubuntu 16.04.I created the phpmyadmin with Php One click install.

Done this 2 line of command in digital ocean console


 sudo a2enmod rewrite
 sudo service apache2 restart

I have my own .htaccess file which is like below

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ %{ENV:BASE}index.php [QSA,L]

And I transferred my file to /var/www/html this directory.

I edit the apache2.config as well like below as well

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

But when I call my api in Postman it show me this result it state url not found.I request my address as http://MY_IP_ADDRESS/example/v1/register ,I am sure is correct URL.

Somebody please tell me what can I do to solve this problem.What am I missing out??

1 Answer

@matchartproduction

What you'd use really depends on how your application is setup to handle requests to index.php.

You may be able to use something such as:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php [NC,L,QSA]

or

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [NC,L,QSA]
  • Sir when I tried what you suggest it give me this error when I call the url

    It show this in Postman,can u give me another suggestion?cause I very new in server code

    WAMP

    PHP 5
    Apache 2.4
    MySQL 5
    Version 3.0.6 - 64bit

    Server Configuration

    Apache Version:
    2.4.23 - Documentation
    PHP Version:
    5.6.25 - Documentation
    Server Software:
    Apache/2.4.23 (Win64) PHP/5.6.25 - Port defined for Apache: 80
    Loaded Extensions :
    apache2handler
    bcmath
    bz2
    calendar
    com_dotnet
    Core

  • or what setting i'm setting wrong?so I can configure out.

Have another answer? Share your knowledge.