Revision 8499
Added by Aaron Marcuse-Kubitza over 11 years ago
web/dotpath.php | ||
---|---|---|
3 | 3 |
|
4 | 4 |
require_once dirname(__FILE__)."/util.php"; |
5 | 5 |
|
6 |
@list($path, $query) = explode("&", $_SERVER["QUERY_STRING"], 2);
|
|
6 |
$path = $_SERVER["QUERY_STRING"];
|
|
7 | 7 |
|
8 | 8 |
## translate dotpaths (after the last /) to /-paths, e.g. d/a.[b.c] -> d/a/b.c |
9 | 9 |
# replace all unescaped . with / , e.g. a.[b.c] -> a/[b.c] |
... | ... | |
12 | 12 |
do |
13 | 13 |
{ |
14 | 14 |
$old_path = $path; |
15 |
$path = preg_replace('/^(.*\/)?(?=.)(\.?[^.\/]*?)(?:\[([^\[\]\/]*)\])?\.([^\/]*)$/',
|
|
15 |
$path = preg_replace('/^([^&]*\/)?(?=.)(\.?[^.\/&]*?)(?:\[([^\[\]\/&]*)\])?\.([^\/&]*)$/',
|
|
16 | 16 |
'$1$2$3/$4', $path); |
17 | 17 |
} while ($path !== $old_path); |
18 | 18 |
|
19 |
$url = ensure_suffix("/", $_SERVER["PATH_INFO"]).$path |
|
20 |
.(isset($query) ? "?&".$query : ""); |
|
19 |
$url = ensure_suffix("/", $_SERVER["PATH_INFO"]).$path; |
|
21 | 20 |
header("Location: ".$url); |
22 | 21 |
?> |
Also available in: Unified diff
web/dotpath.php: just match the QUERY_STRING directly, excluding &, instead of splitting apart the QUERY_STRING and then matching the dotpath portion. this allows the resulting regexp to be used directly in a .htaccess file.