Error: Page cannot be located 404 (GET /) • Directory not found: C:/wamp/www/fatfree-master/index.php:111 Base->execute()

Recently, I decided to give the php fat free framework (also known as F3) a try in order to quickly construct a web application.

Despite reading through the documentation and thinking it would be straightforward, I have been encountering a single issue that has stumped me for days. It appears from similar queries on stackoverflow that I am not alone in facing this challenge.

Here are some pertinent details:

  • I am utilizing wamp server to execute F3.
  • The location of my F3 project is at /location-to-wamp-folder/www/fatfree-master.
  • I have configured a virtual host for Apache within wamp so that points to index.php.

This is where my difficulties arise. Upon navigating to http/fatfree-master, I encounter the error detailed in the title of this post:

Not Found

HTTP 404 (GET /) C:/wamp/www/fatfree-master/index.php:111 Base->run()

The contents of my index.php are as follows:

<?php

$f3=require('lib/base.php');

$f3->set('DEBUG',3);
$f3->set('UI','ui/');

....
// custom PHP code defining routes etc ...
....

$f3->run();  // this is where an error occurs

While I acknowledge that I am not well-versed in Apache rewrite syntax, I have refrained from making any changes to my .htaccess file (which was provided with the F3 download).

Below are the contents of my default .htaccess file included with F3:

# Enable rewrite engine and route requests to framework
RewriteEngine On

# Some servers require you to specify the `RewriteBase` directive
# In such cases, it should be the path (relative to the document root)
# containing this .htaccess file
#
# RewriteBase /

RewriteRule ^(tmp)\/|\.ini$ - [R=404]

RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L,QSA]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]

If anyone can shed light on why I am receiving the 404 error and offer solutions, it would be greatly appreciated.

[[Additional Notes]]

I have integrated two routes into my revised index.php file. The current version looks like this:

<?php

$f3=require('lib/base.php');
$f3->set('AUTOLOAD','app/controllers/');

$f3->set('DEBUG',3);
$f3->set('UI','ui/');

/* Tools */
$f3->route('GET @tools_calculator_dates: /tools/calculator/dates', 'Beer->list');

// Default route
$f3->route('GET /',
    function() {
        echo 'Hello, world!';
    }
);

$f3->run();

Upon accessing / in my browser, "Hello, world!" is displayed as expected. However, when attempting to access /tools/calculator/dates, a 404 error is returned:

Not Found

HTTP 404 (GET /tools/calculator/dates)

• C:/wamp/www/fatfree-master/index.php:119 Base->run()

In my directory structure, I have a class located at /path/to/wamp/www/fatfree-master/app/controllers/beer.php

Here is the content of the class:

<?php
class Beer
{
    function list() {
        echo "Beer::list() called!";
    }
}

If anyone can provide insight into why the 404 error is occurring, I would greatly appreciate it.

Answer №1

The issue you are encountering is not originating from Apache, but rather from F3.

When no route for GET / is provided, F3 will generate a 404 error.

Answer №2

If you're encountering a 404 error, it could be due to one of the following reasons:

  1. The route you are trying to access may not have been properly defined.
  2. The class or method associated with the route may be missing or inaccessible.
  3. If you are running the web app in a subfolder, enabling RewriteBase might resolve the issue.

For more information on point #1, refer to the official documentation.

To address point #2, consider reading this helpful answer if you are struggling with setting up the framework's autoloader (AUTOLOAD variable).

In relation to point #3: while RewriteBase is generally not necessary for subfolders, certain circumstances (such as when mod_userdir is active) may require explicit configuration.

If needed, you can try adding the following directive to your .htaccess file after RewriteEngine On:

RewriteBase /your-subfolder/

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

A div containing a form, with the form being visually integrated within the div

Hi everyone, this is my first post here and I've tried to search extensively before asking this question. I've attempted to use the following examples without success: jquery submit form and then show results in an existing div Form submit ...

Tips for choosing classes with identical names without resorting to incremental IDs

https://i.stack.imgur.com/EVQVF.pngAre there alternative methods to select classes with the same name but in different table rows? Currently, I am using html class="className + id" and then in jquery to select $('.className'+id)... some code. Is ...

There seems to be some incomplete information in an image file that was extracted from the MSSQL database

I am facing an issue where I am unable to display the full image stored in the Image field of the database. Currently, only a partial image of 63KB is being displayed. Here is the code I am using: $sql='SELECT Photo FROM Personel WHERE ID_USER = &ap ...

We're sorry, but the URL you were trying to access at /emr/login could not be found on this server

I recently began a new project using Laravel. Once I installed and updated the Composer, I ran my project and was able to see the home page. However, when I tried to access the Login Page of my project, it showed an error message: The requested URL /emr ...

Converting query strings to paths in CodeIgniter using Apache's .htaccess configuration

Need help with converting URLs on a CodeIgniter based website from index.php?option=test&controller=con1 to /test/con1 using .htaccess. I've tried various examples found online but none of them seem to work, as the site keeps redirecting to the ho ...

Include a control parameter in the $_REQUEST array within your WordPress and PHP code

I am seeking a way to transfer a variable between pages in WordPress. The variable, named "season", acts as a control variable for the entire site and is initially set to the current season (a custom variable in the admin panel). It can be updated through ...

Extracting Data from JSON Objects Using PHP

array(85) { [0]=> object(stdClass)#9 (18) { ["offer_id"]=> string(8) "12345678" ["offer_name"]=> string(39) "Offer Name" ["offer_desc"]=> string(209) "Offer Description" ["call_to_action"]=> string(57) "Of ...

What is the best way to iterate over an indexed attribute in PHP?

Here is my ajax code snippet: $.ajax({ type: "POST", url: "bee_sesi_edit.php", data: 'serv_ruang='+ serv_ruangx +'&who='+names +'&sesi_d1='+ sesi_d1 +&apos ...

Explaining the implementation of JQuery's onload event and its impact on reducing dependencies

Contained within a table is some data https://i.stack.imgur.com/gQyJQ.png Upon clicking the edit button, I am able to modify the information in that specific row. The Menu Category and Menu are populated through Dependent dropdowns. https://i.stack.imgur ...

A guide on initiating a Curl request

Seeking assistance with Instagram authentication code in PHP and Curl. In order to request the access_token, you need to follow these steps: Step Three: Request the access_token To exchange the code for an access token, you must POST the code along with ...

Access the value retrieved from a form on the previous page using PHP

I'm struggling with extracting values from radio buttons on a previous page. Currently, my HTML and PHP code works fine with the search bar, which is the first form below. However, I'd like to add radio button filters below the search bar. <s ...

Could concurrent HTTP requests with cURL be the solution?

Let me preface this by saying that I'm relatively new to this, so please bear with me. I have a specific task in mind and could use some guidance on finding the right solution. Currently, I have multiple web forms that need to be sent across domains u ...

Looking to display the "loading....." message on a PHP page?

I am working on a PHP webpage where I need to implement the following features: 1. Upon clicking "Say Thanks", it should change to "Done!". 2. Simultaneously, I would like to trigger an action in the indexController. 3. While this action is happening, I wa ...

Looking for a way to optimize query performance within a loop? Concerned about memory constraints?

I have created a custom shopping cart component for my Joomla website. Users are buying codes that we store in our database, which are linked to physical incentive cards. During checkout, I need to retrieve the purchased codes from the database and then up ...

Guide to displaying WordPress functions within an accordion in my loop

Currently, I'm working on implementing a vertical accordion feature that will display blog posts within each section. The idea is to have 5 of the most recent posts displayed in the accordion, with each post showing the date (day/month/year) and title ...

What is the best way to incorporate two foreach loops in Laravel within a single view?

<h2 class="section-subheading text-muted text-center">First Course</h2> <div class="row text-center"> @foreach ($data as $item) <div class="col-md-4 px-3"> <div cl ...

Issue with using Javascript variables within Highcharts

I am facing an issue with displaying a high charts pie chart dynamically. When I pass the exact value format into the data index in the high chart, it doesn't show anything in the chart. However, if I directly assign a value to a variable, it works fi ...

Error Encountered: Codeception WebCurlException

Currently, I am using Codeception in conjunction with Selenium Webdriver and encountering a WebCurlException Error once I execute codecept.phar. Here are the steps I've taken: 1. I initiated the selenium stand alone server jar file via the command p ...

Tips on proceeding with this countdown

I have a start date stored in the database Now, I retrieve the current date which is assumed to be in UTC timezone class Datecalc { public $year; public $month; public $day; public $hour; public $minute; public $second; fun ...

Setting up aspell or pspell on your XAMPP server

I am working on developing a web application using PHP to verify if a word is valid or exists in the English language dictionary. However, I find the instructions unclear and many of the solutions on Stack Overflow seem outdated. Can you please provide me ...