- Code: Select all
<VirtualHost *:80>
<Directory /var/www/html/webserver/public>
Allow From All
AllowOverride All
Options -Indexes
</Directory>
DocumentRoot /var/www/html/webserver/public
ServerName ./install.sh
</VirtualHost>
<VirtualHost *:80>
<Directory /var/www/html/webserver/public>
Allow From All
AllowOverride All
Options -Indexes
</Directory>
DocumentRoot /var/www/html/webserver/public
ServerName www.test.com
ServerAlias www.test.com
Redirect permanent / https://test.com/
RewriteEngine on
#RewriteBase /
RewriteCond %{SERVER_NAME} =www.test.com [OR]
RewriteCond %{SERVER_NAME} =test.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
This works perfectly for http -> https redirection. For example test.com or http://test.com redirects to https://test.com. www.test.com does not work (i don't know why?), i'll get a 404 page. Next big thing, lets assume the ip of my webserver is 12.23.45.67 - how do i have to change my config file, so this ip also redirects to https://test.com?