diff --git a/src/php/.htaccess b/src/php/.htaccess index 43599f9..973cfb6 100644 --- a/src/php/.htaccess +++ b/src/php/.htaccess @@ -1,12 +1,12 @@ RewriteEngine On # Turn on the rewriting engine -RewriteRule ^view/([0-9]+)/([0-9]+)/?$ api/router.php?view=word&dict=$1&word=$2 [NC,L] # Handle word ids. +RewriteRule ^view/([0-9]+)/([0-9]+)/?$ router.php?view=word&dict=$1&word=$2 [NC,L] # Handle word ids. -RewriteRule ^([0-9]+)/([0-9]+)/?$ api/router.php?view=word&dict=$1&word=$2 [NC,L] # Handle word ids. +RewriteRule ^([0-9]+)/([0-9]+)/?$ router.php?view=word&dict=$1&word=$2 [NC,L] # Handle word ids. -RewriteRule ^view/([0-9]+)/?$ api/router.php?view=dictionary&dict=$1 [NC,L] # Handle dictionary ids. +RewriteRule ^view/([0-9]+)/?$ router.php?view=dictionary&dict=$1 [NC,L] # Handle dictionary ids. -RewriteRule ^([0-9]+)/?$ api/router.php?view=dictionary&dict=$1 [NC,L] # Handle dictionary ids. +RewriteRule ^([0-9]+)/?$ router.php?view=dictionary&dict=$1 [NC,L] # Handle dictionary ids. #RewriteRule ^issues/?$ https://github.com/Alamantus/Lexiconga/issues [R=301,L] # Shorten issues url. diff --git a/src/php/api/router.php b/src/php/router.php similarity index 86% rename from src/php/api/router.php rename to src/php/router.php index 4a7e6d5..5a26fe1 100644 --- a/src/php/api/router.php +++ b/src/php/router.php @@ -1,12 +1,13 @@ getPublicDictionaryDetails($dict); if ($dictionary_data !== false) { @@ -22,16 +23,16 @@ switch ($view) { $html = str_replace('{{public_name}}', 'Error', $html); $html = str_replace('{{dict_json}}', '{"name": "Error:", "specification": "Dictionary Not Found", "words": []}', $html); } - echo $html; + return Response::html($html); } break; } case 'word': { - $html = file_get_contents('../template-view.html'); + $html = file_get_contents(realpath(dirname(__FILE__) . '/./template-view.html')); $dict = isset($_GET['dict']) ? $_GET['dict'] : false; $word = isset($_GET['word']) ? $_GET['word'] : false; if ($dict !== false && $word !== false) { - require_once('./Dictionary.php'); + require_once(realpath(dirname(__FILE__) . '/./api/Dictionary.php')); $dictionary = new Dictionary(); $dictionary_data = $dictionary->getPublicDictionaryDetails($dict); if ($dictionary_data !== false) { @@ -61,7 +62,7 @@ switch ($view) { $html = str_replace('{{public_name}}', 'Error', $html); $html = str_replace('{{dict_json}}', '{"name": "Error:", "specification": "Dictionary Not Found", "words": []}', $html); } - echo $html; + return Response::html($html); } break; }