diff options
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | scripts/build-rewritemap.php | 21 |
2 files changed, 22 insertions, 0 deletions
@@ -4,5 +4,6 @@ /build.properties /dist /lib/ +/src/gen-rewritemap.php /www/*.phar /www/*.phar.bz2 diff --git a/scripts/build-rewritemap.php b/scripts/build-rewritemap.php new file mode 100644 index 0000000..354af7f --- /dev/null +++ b/scripts/build-rewritemap.php @@ -0,0 +1,21 @@ +<?php +/** + * Convert the .htaccess rewrite rules into an array of pattern-replacement + * pairs. + * Writes src/gen-rewritemap.php + */ +$lines = file(__DIR__ . '/../www/.htaccess'); +$patterns = array(); +foreach ($lines as $line) { + if (substr($line, 0, 11) == 'RewriteRule') { + list($n, $pattern, $replace) = explode(' ', rtrim($line)); + $patterns['#' . $pattern . '#'] = $replace; + } +} +file_put_contents( + __DIR__ . '/../src/gen-rewritemap.php', + "<?php\n/* automatically created from www/.htaccess */\nreturn " + . var_export($patterns, true) + . ";\n?>\n" +); +?> |
