Object not found in apache

I’m using manjaro and i installed mariadb, apache, php, php-apache, and phpmyadmin. if i request to /myUrl/api/ I got:

  "ok": false,
  "code": null,
  "message": null,
  "result": [

This result. But when i try with some exist methods for example /myUrl/api/login i got

Object not found!
The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.

If you think this is a server error, please contact the webmaster.

Error 404
Apache/2.4.56 (Unix) PHP/8.2.4

Here my .htaccess code

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews

    RewriteEngine On

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

I tried to enable mod_rewrite and I uncommented #LoadModule rewrite_module modules/mod_rewrite.so in /etc/httpd/conf/httpd.conf and also I did sudo a2enmod rewrite and restarted httpd however result not changed. I’m new so please give detailed answer. Thanks

This just means that there is no file, folder, aliases or a rewrite by the name login. You need to make sure it is available, or apache will tell you that it can’t find it.

I’m sure there are login method and necessary files

There is a folder or file called login in a folder called api? Then please show the ls output of the folder api.

there’s folder called api but not file called login. Login is method in index.php. In api folder there are .htaccess and index.php

If your URL uses a / in front of login a file, folder, rewrite or alias is required. Get in touch with the developer of your API and ask what you need to do to use the login method. This is usually done by a request to the api with some payload or parameters in the URL.

look, i think problem on apache i have to do smth with it. coz i uploaded same code to hosting and i got result that i want

@foxdevuz , you need to configure your Apache to allow to apply settings in the .htaccess file of the directory where it is inside.
Otherwise the settings inside the .htaccess file are ignored…
Plus you need to allow overriding/enabling rewrites inside the .htaccess file via configuration settings inside the main Apache config…

Carefully examine the config of both Apache’s using the /server-info URL if you have it enabled, which i highly recommend (and needs to be protected for local access only or similar): mod_info - Apache HTTP Server Version 2.4

So unless you know exactly how to configure Apache, some things are best done inside the Apache main config instead of .htaccess files, because that needs extra permissions configured…

PS: I added the configuration tag to your thread :wink:

Hi foxdevuz

The “Object not found” error you are encountering in Apache typically indicates that the requested URL does not match any existing files or routes on the server. Here are a few steps you can take to troubleshoot and resolve the issue:

    1. Confirm the URL structure: Double-check the URL you are requesting and ensure that it matches the correct structure and case sensitivity expected by your application. For example, if your application expects lowercase URLs, make sure you are using lowercase in the URL.
  • Verify the existence of the file or route: Make sure that the file or route you are trying to access actually exists in the appropriate location on the server. Confirm that the file or route is accessible and in the correct directory as expected by your application.

  • Check the Apache configuration: Review the Apache configuration file (httpd.conf) to ensure that the necessary settings for URL rewriting and mod_rewrite are properly enabled and configured. Confirm that the .htaccess file is being read and processed by Apache. Make sure there are no conflicting rules or directives in the configuration file that could interfere with the routing of your requests.

  • Verify the .htaccess file: Check the .htaccess file in the appropriate directory (typically the document root) for any errors or misconfigurations. Ensure that the RewriteEngine directive is set to “On” and that the rewrite rules are correctly defined.

  • Restart Apache: After making changes to the Apache configuration or the .htaccess file, restart the Apache service to ensure that the changes take effect.

  • Check file and directory permissions: Ensure that the files and directories involved in the routing process have the necessary permissions for Apache to access them. Verify that the Apache user (e.g., www-data) has appropriate read and execute permissions for the files and directories involved.

  • Enable error logging: Enable error logging in the Apache configuration to capture any additional error messages that could help pinpoint the issue. Review the Apache error log file (typically located in /var/log/apache2/error.log or a similar location) for any relevant error messages.

Please note that the exact steps and configurations may vary depending on your specific setup and operating system.