Ondra3211
Contributor
- May 5, 2018
- 65
- 37
- 111
Hi, Does anyone know how to make the best redirects to www?
I have Apache2 and I need it this:
I have Apache2 and I need it this:
Code:
http://domain.tld -> https://www.domain.tld
https://domain.tld -> https://www.domain.tld
http://www.domain.tld -> https://www.domain.tld
www-domain config
domain config
Apache config:
<VirtualHost *:80>
<Directory "/var/www/html">
AllowOverride All
</Directory>
ServerName www.******.eu
ServerAdmin ******@*****.eu
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.******.eu
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
Apache config:
<VirtualHost *:80>
<Directory "/var/www/html">
AllowOverride All
</Directory>
ServerName ******.eu
ServerAdmin ******@******.eu
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>