I have a VPS server with Apache, FastCGI and php-fpm installed. But, the .htaccess files seems be ignored. I have a .htaccess file that redirects http URLs to https URLs:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L]
</IfModule>
But the rules are ignored and no redirect happens.
Here is my virtual host file (I changed the domain to example.com):
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/example.com/public
<Directory />
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Include /etc/apache2/conf-available/php7.0-fpm.conf
</VirtualHost>
The apache rewrite module seems be enabled. When I run sudo apache2ctl -M
, the rewrite_module (shared)
is showed on output.
Any help will be very appreciated. Thanks.