Routing is not working with docker – PHP + APACHE + DOCKER – 404 NOT FOUND

  docker, php, routes

I implemented an application (php+postgres+apache) with docker, created dockerfile and docker-compose and everything went well, except the route system. The first route "/" is working, but not the others.

Dockerfile

FROM php:8-apache 

# this is default folder in Apache
ENV WORK_DIR=/var/www/html

RUN apt-get update 

RUN apt-get install -y 
    libpq-dev

RUN docker-php-ext-install pdo && 
    docker-php-ext-install pdo_pgsql

COPY www/ ${WORK_DIR}

docker-compose.yml

version: "3.1"

services:
    www:
        build: .
        restart: always
        ports: 
            - '8000:80'
        volumes:
            - ./www:/var/www/html
        networks: 
            - default
    db:
        image: postgis/postgis
        restart: always
        ports:
            - '5432:5432'
        environment:
            - POSTGRES_DB=postgres
            - POSTGRES_USER=postgres
            - POSTGRES_PASSWORD=postgres
        volumes:
            - db_data:/var/lib/pgsql
        networks: 
            - default
    db-pgadmin:
        image: dpage/pgadmin4
        environment:
            PGADMIN_DEFAULT_EMAIL: "[email protected]"
            PGADMIN_DEFAULT_PASSWORD: "postgres"
        ports:
            - "16543:80"
        depends_on:
            - db
        networks:
            - default volumes:
    db_data:

The structure of my application is:

-www
--core
--public
--src

at my public folder I am using the following config

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

    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

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

    # Send Requests To Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

Please, I would really appreciate if someone help me

Source: Docker Questions

LEAVE A COMMENT