diff --git a/builder b/builder index 2b5eeeaa..1ec7d50f 100755 --- a/builder +++ b/builder @@ -234,7 +234,7 @@ rcopy($path_debug_assets."templates/", $path_release_assets."templates/"); //Copy dark theme rcopy($path_debug_assets."css/dark_theme.css", $path_release_assets."css/dark_theme.css"); -//Create main HTML file +//Begin to write root PHP File notice("Generate PHP root file"); $page_src = ''; -$page_src .= load_page($release_conf); -file_put_contents(OUTPUT_DIRECTORY."index.php", $page_src); +}'; -// Add .htaccess file +// Begin .htaccess file $htaccess = ' RewriteEngine On RewriteRule ^index\.php$ - [L] @@ -271,11 +269,21 @@ if(defined(get_class($release)."::FORCE_HTTPS")){ $htaccess .= "\n\nRewriteCond %{HTTPS} !on\n"; $htaccess .= "RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}"; + //Add rules in root PHP file + $page_src .= "\n//Force HTTPS connection\n"; + $page_src .= "if(!isset(\$_SERVER[\"HTTPS\"]) || \$_SERVER[\"HTTPS\"] != \"on\")\n"; + $page_src .= "\theader('Location: https://'.\$_SERVER['HTTP_HOST'].\$_SERVER['REQUEST_URI']);\n"; } } + +//Write .htaccess file file_put_contents(OUTPUT_DIRECTORY.".htaccess", $htaccess); +//Write root index file +$page_src .= ' ?>'; +$page_src .= load_page($release_conf); +file_put_contents(OUTPUT_DIRECTORY."index.php", $page_src); //Done notice("Done.", TRUE);