It sounds like you might be running into an issue with URL rewriting, which is common when using a custom PHP router on a local server like WAMP. Here's what you can do to troubleshoot and fix the issue:
-
Enable mod_rewrite: Make sure that the
mod_rewritemodule is enabled in your WAMP server. You can do this by clicking on the WAMP icon in your system tray, going to the Apache modules, and ensuring thatrewrite_moduleis checked. -
Create a .htaccess file: If you haven't already, you need to create a
.htaccessfile in the root directory of your project. This file will tell Apache to redirect all requests to yourindex.phpfile, where your router will handle them. Here's a basic example of what this file might look like:
Options -MultiViews
RewriteEngine On
RewriteBase /your_project_folder/
# Redirect all requests to index.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
Replace /your_project_folder/ with the actual subdirectory of your project if it's located in a subdirectory of www or htdocs. If your project is directly in the www or htdocs folder, you can set RewriteBase /.
-
AllowOverride directive:
Ensure that the
AllowOverridedirective is set toAllfor your project directory in the Apache configuration file (httpd.conf). This allows.htaccessfiles to override the server configuration settings.
<Directory "/path/to/your/project">
AllowOverride All
</Directory>
-
Restart WAMP: After making these changes, restart your WAMP server to ensure that the new configuration is applied.
-
Check your router configuration: Make sure that your router is set up to handle requests to the about and contact pages. Your
index.phpfile should include logic to handle different URIs and direct them to the appropriate controllers or views.
If you've followed these steps and are still encountering issues, please provide more details about your router setup and any error messages you're seeing. This will help in diagnosing the problem further.