From 0724dcda2412212e7642a9605bdeba0e35716dc1 Mon Sep 17 00:00:00 2001 From: William Date: Fri, 1 Jul 2022 14:41:50 +0200 Subject: [PATCH] =?UTF-8?q?Ajout=20du=20mod=20rewrite=20pour=20prendre=20e?= =?UTF-8?q?n=20compte=20toutes=20les=20requ=C3=AAtes.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 4 +++- public/.htaccess | 21 +++++++++++++++++++++ public/index.php | 2 +- 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 public/.htaccess diff --git a/Dockerfile b/Dockerfile index 00da9a2..fa03975 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,6 +26,9 @@ COPY vhost.conf /etc/apache2/sites-available/000-default.conf RUN docker-php-ext-configure gd --with-freetype --with-jpeg \ && docker-php-ext-install pdo pdo_mysql mbstring exif pcntl bcmath gd zip curl intl +# Enable Apache mods +RUN a2enmod rewrite + # Clean cache RUN apt-get -y autoremove \ && apt-get clean \ @@ -33,4 +36,3 @@ RUN apt-get -y autoremove \ # Copy source code COPY . /var/www - diff --git a/public/.htaccess b/public/.htaccess new file mode 100644 index 0000000..3aec5e2 --- /dev/null +++ b/public/.htaccess @@ -0,0 +1,21 @@ + + + Options -MultiViews -Indexes + + + 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] + diff --git a/public/index.php b/public/index.php index 65bfbca..6430354 100644 --- a/public/index.php +++ b/public/index.php @@ -1,3 +1,3 @@