FIX #550 Webhosting http redirect

This commit is contained in:
Ulrich Block 2016-12-11 15:36:41 +01:00
parent 96ed044f85
commit 7082bef10b
2 changed files with 28 additions and 4 deletions

View File

@ -44,8 +44,15 @@ function loadServerSettings (serverType, usageType) {
defaultRestartCMD = 'sudo /etc/init.d/nginx reload';
/* Add redirect from www. -> non www. */
defaultVhostTemplate = 'server {\r\n';
defaultVhostTemplate += ' listen 80;\r\n';
defaultVhostTemplate += ' server_name www.%domain%;\r\n';
defaultVhostTemplate += ' return 301 $scheme://%domain%$request_uri;\r\n';
defaultVhostTemplate += '}\r\n';
defaultVhostTemplate += 'server {\r\n';
defaultVhostTemplate += ' listen 80;\r\n';
defaultVhostTemplate += ' server_name %domain%;\r\n';
defaultVhostTemplate += ' autoindex off;\r\n';
defaultVhostTemplate += ' access_log %vhostpath%/%user%/%logDir%/access_%domain%.log;\r\n';
@ -89,7 +96,13 @@ function loadServerSettings (serverType, usageType) {
defaultRestartCMD = 'sudo /etc/init.d/apache2 reload';
/* Add redirect from www. -> non www. */
defaultVhostTemplate = '<VirtualHost *:80>\r\n';
defaultVhostTemplate += ' ServerName www.%domain%\r\n';
defaultVhostTemplate += ' ServerName Redirect 301 / http://%domain%/\r\n';
defaultVhostTemplate += '</VirtualHost>\r\n';
defaultVhostTemplate += '<VirtualHost *:80>\r\n';
defaultVhostTemplate += ' ServerAdmin %email%\r\n';
defaultVhostTemplate += ' DocumentRoot "%vhostpath%/%user%/%htdocs%/%path%"\r\n';
defaultVhostTemplate += ' ServerName %domain%\r\n';

View File

@ -151,9 +151,15 @@ php_admin_flag mod_rewrite off = OFF';
if (!$vhostTemplate or strlen($vhostTemplate) < 2) {
if ($serverType == 'N') {
$vhostTemplate = 'server {
listen 80;
server_name www.%domain%;
return 301 $scheme://%domain%$request_uri;
}';
if ($usageType == 'F') {
$vhostTemplate = 'server {
$vhostTemplate .= 'server {
listen 80;
server_name %domain%;
autoindex off;
@ -167,7 +173,7 @@ if (!$vhostTemplate or strlen($vhostTemplate) < 2) {
} else {
$vhostTemplate = 'server {
$vhostTemplate .= 'server {
listen 80;
server_name %domain%;
autoindex off;
@ -201,9 +207,14 @@ allow_url_include=Off
} else if ($serverType == 'A') {
$vhostTemplate = '<VirtualHost *:80>
ServerName www.%domain%
ServerName Redirect 301 / http://%domain%/
</VirtualHost>';
if ($usageType == 'F') {
$vhostTemplate = '<VirtualHost *:80>
$vhostTemplate .= '<VirtualHost *:80>
ServerAdmin %email%
DocumentRoot "%vhostpath%/%user%/%htdocs%/%path%"
ServerName %domain%
@ -224,7 +235,7 @@ allow_url_include=Off
} else {
$vhostTemplate = '<VirtualHost *:80>
$vhostTemplate .= '<VirtualHost *:80>
ServerAdmin %email%
DocumentRoot "%vhostpath%/%user%/%htdocs%/%path%"
ServerName %domain%