diff options
author | Tarulia <takuja@gmx.de> | 2015-09-26 05:04:45 +0300 |
---|---|---|
committer | Tarulia <takuja@gmx.de> | 2015-09-26 05:04:45 +0300 |
commit | 64ca436d3971fcb5a83802efa28e0efe24493626 (patch) | |
tree | 78c88d1681a8e86dfe36dff115742e640fde914c | |
parent | e56fd23b39daaf364e0098bee12890753ac717a7 (diff) |
[setup] Proper check for trailing slash on path
* also fixed double slash // in .nginx-config
-rw-r--r-- | setup.php | 21 |
1 files changed, 12 insertions, 9 deletions
@@ -128,7 +128,10 @@ PHP; require_once('lib-core.php'); $path = $_POST['path']; - if (strlen($path) > 2) { // why 2? Is a folder like /r possible? + // check if path ends with / , validating it for .htaccess + if ( !(substr( $path, -1) == "/") ) { + die("<p class='alert alert-danger'>Path needs trailing slash (<code>/</code>).</p>"); + } else { $data = "<IfModule mod_rewrite.c> RewriteEngine On RewriteBase $path @@ -157,18 +160,18 @@ PHP; listen 80; server_name %SERVER_NAME%; index index.php - location = $path/api { - rewrite ^(.*)$ $path/api.php; + location = {$path}api { + rewrite ^(.*)$ {$path}api.php; } - location $path/ { + location {$path} { if (!-e \$request_filename){ - rewrite ^$path/([a-zA-Z0-9]+)\?([a-zA-Z0-9]+)$ $path/r.php?u=$1&lkey=$2; + rewrite ^{$path}([a-zA-Z0-9]+)\?([a-zA-Z0-9]+)$ {$path}r.php?u=$1&lkey=$2; } - rewrite ^$path/([a-zA-Z0-9]+)/?$ $path/r.php?u=$1; - rewrite ^$path/?\+([a-zA-Z0-9]+)$ $path/stats.php?bv=$1; + rewrite ^{$path}([a-zA-Z0-9]+)/?$ {$path}r.php?u=$1; + rewrite ^{$path}?\+([a-zA-Z0-9]+)$ {$path}stats.php?bv=$1; } - location $path/t { - rewrite ^$path/t-([a-zA-Z0-9]+)/?$ $path/r.php?u=t-$1; + location {$path}t { + rewrite ^{$path}t-([a-zA-Z0-9]+)/?$ {$path}r.php?u=t-$1; } }"; $handle = fopen('.nginx-config', 'w'); |