Apache's 000-default.conf - weird behaviour
1
vote
1
answer
4489
views
I'm trying to achieve a redirect from
example.com
to www.example.com
(non-www to www).
My **sites-available/example.com.conf
** file looks like this;
ServerName www.example.com
ServerAdmin unidan@example.com
DocumentRoot /var/www/example.com/public_html
ErrorLog /var/www/example.com/logs/error.log
CustomLog /var/www/example.com/logs/access.log combined
ServerName example.com
Redirect permanent / http://www.example.com
ServerName example.com
Redirect permanent / https://www.example.com
My **sites-available/000-default.conf
** file looks like this;
ServerAdmin zuckerberg@facebook.com
DocumentRoot /var/www/default/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Now.. when requesting http://www.example.com
it will respond as requested. However, when requesting http://example.com
it will render the request using the configuration in 000-default.conf
.
Unlinking 000-default.conf
from sites-enabled/
will fix this issue, however this is not something I want to do (I want to keep a default behaviour for unknown requests).
What is the issue here? Why does the configuration in 000-default.conf
override the redirect?
Asked by William Boman
(131 rep)
Sep 3, 2014, 09:49 PM
Last activity: Jul 8, 2018, 08:01 PM
Last activity: Jul 8, 2018, 08:01 PM