I want to dockerize an existing PHP website but I am running into an issue. Can you help me to understand what is happening here?
Issue
The index.php page loads fine. However, all other pages such as about.php are not loading. It produces the error message shown below. I would like to understand why I cannot navigate to other pages.
I've verified that the project files are being copied to the docker container by connecting using the following command:
docker exec -it <container_id> bash
Looking at the code, we aren't using any third party libraries so I don't think it's a router type of issue. This is a basic website with little PHP functionality.
What's interesting is that I can run this site on my laptop using the default MacOS apache web server. The pages load fine. There must be a configuration in the docker image that I might need to change, but I am unsure what that would be.
Dockerfile
FROM php:8.2.5-apache as php
WORKDIR /var/www/html
COPY ./ ./
EXPOSE 80
Error
404 Not Found
The requested URL was not found on this server.
Apache/2.4.56 (Debian) Server at localhost Port 80
Thank you for your guidance.
ls -la /var/www/html? What was the result? Please edit your question to include details of the files you expect to work and the exact URLs you're trying to open in your browser. I suspect this is a filename case problem since Linux file systems are case-sensitive.phpextension. It seems the developer had left off the.phpextensions and I didn't pick up on that.http://localhost/about.phpworks, but the code has links like/aboutinstead. This must have been intentional and I'll start researching how to handle the scenario where we drop off the file extension. Thank you for pointing that out..htaccessfile that'd allow URL rewriting to occur and show the URL's without the.phpextension?