I use docker compose. However, when I run \"docker-compose up\", I came across an error : /var/www/html/.htaccess: Invalid command \'RewriteEngine\'.
Can you tell me
This works for me:
# Dockerfile
FROM php:5.6-apache
MAINTAINER Raphael Mäder <me@randm.ch>
RUN a2enmod rewrite
ADD . /var/www/html
Don't forget to run your docker-compose up
command with --build
if you have already built the image previously, otherwise it will run the old image which may have not included the RUN a2enmod rewrite
statement.
Add this to your Dockerfile:
# Enable mod_rewrite for images with apache
RUN if command -v a2enmod >/dev/null 2>&1; then \
a2enmod rewrite headers \
;fi