/** * @return RuleInterface */ protected function getPrettyUrlRule() { $rule = new Rule(function (Rule $rule) { $DIR_REL = $rule->getOption('dir_rel')->getValue(); if ($DIR_REL === null) { if (\Core::make('app')->isRunThroughCommandLineInterface()) { throw new Exception(t('When executed from the command line, you need to specify the %s option', 'dir_rel')); } else { $DIR_REL = DIR_REL; } } $DIR_REL = trim((string) $DIR_REL, '/'); if ($DIR_REL !== '') { $DIR_REL = '/' . $DIR_REL; } $DISPATCHER_FILENAME = DISPATCHER_FILENAME; return <<<EOT <IfModule mod_rewrite.c> \tRewriteEngine On \tRewriteBase {$DIR_REL}/ \tRewriteCond %{REQUEST_FILENAME} !-f \tRewriteCond %{REQUEST_FILENAME}/index.html !-f \tRewriteCond %{REQUEST_FILENAME}/index.php !-f \tRewriteRule . {$DISPATCHER_FILENAME} [L] </IfModule> EOT; }, function () { return (bool) \Config::get('concrete.seo.url_rewriting'); }, "# -- concrete5 urls start --", "# -- concrete5 urls end --"); $option = new RuleOption(t('concrete5 path relative to website root'), function () { return \Core::make('app')->isRunThroughCommandLineInterface(); }); $rule->addOption('dir_rel', $option); return $rule; }
/** * @return RuleInterface */ protected function getPrettyUrlRule() { $DIR_REL = DIR_REL; $DISPATCHER_FILENAME = DISPATCHER_FILENAME; $rule = new Rule(function (Rule $rule) { $DIR_REL = $rule->getOption('dir_rel')->getValue(); if ($DIR_REL === null) { if (\Core::make('app')->isRunThroughCommandLineInterface()) { throw new Exception(t('When executed from the command line, you need to specify the %s option', 'dir_rel')); } else { $DIR_REL = DIR_REL; } } $DIR_REL = trim((string) $DIR_REL, '/'); if ($DIR_REL !== '') { $DIR_REL = '/' . $DIR_REL; } $DISPATCHER_FILENAME = DISPATCHER_FILENAME; return <<<EOT location {$DIR_REL}/ { \tset \$do_rewrite 1; \tif (-f \$request_filename) { \t\tset \$do_rewrite 0; \t} \tif (-f \$request_filename/index.html) { \t\tset \$do_rewrite 0; \t} \tif (-f \$request_filename/index.php) { \t\tset \$do_rewrite 0; \t} \tif (\$do_rewrite = "1") { \t\trewrite ^/(.*)\$ /{$DISPATCHER_FILENAME}/\$1 last; \t} } EOT; }, function () { return (bool) \Config::get('concrete.seo.url_rewriting'); }, "# -- concrete5 urls start --", "# -- concrete5 urls end --"); $option = new RuleOption(t('concrete5 path relative to website root'), function () { return \Core::make('app')->isRunThroughCommandLineInterface(); }); $rule->addOption('dir_rel', $option); return $rule; }