From 73ec58cc3bdbc07417ea3674ecdea1ee3ba25948 Mon Sep 17 00:00:00 2001 From: Kenji ITO Date: Sun, 24 Jan 2016 06:20:08 +0900 Subject: [PATCH] Modified to allow routes to start with "/index.php?" (not with "/index.php/") --- language/english.php | 2 +- language/english_utf-8.php | 2 +- language/japanese_utf-8.php | 2 +- public_html/admin/router.php | 4 ++-- public_html/docs/english/config.html | 3 ++- public_html/docs/japanese/config.html | 2 +- 6 files changed, 8 insertions(+), 7 deletions(-) diff --git a/language/english.php b/language/english.php index 0d7f06ef0..b5b40126b 100644 --- a/language/english.php +++ b/language/english.php @@ -1355,7 +1355,7 @@ 13 => 'Rule is a mandatory item.', 14 => 'Route is a mandatory item.', 15 => 'Placeholders (@) in a rule and those in a route must be the same.', - 16 => 'Route must not start with "index.php".', + 16 => 'Route must not start with "/index.php/".', 17 => 'Database error occurred.', 18 => 'To enable URL routing, you have to enable URL rewrite.', 19 => '', diff --git a/language/english_utf-8.php b/language/english_utf-8.php index d5e70af6d..f0b7f8e92 100644 --- a/language/english_utf-8.php +++ b/language/english_utf-8.php @@ -1355,7 +1355,7 @@ 13 => 'Rule is a mandatory item.', 14 => 'Route is a mandatory item.', 15 => 'Placeholders (@) in a rule and those in a route must be the same.', - 16 => 'Route must not start with "index.php".', + 16 => 'Route must not start with "/index.php/".', 17 => 'Database error occurred.', 18 => 'To enable URL routing, you have to enable URL rewrite.', 19 => '', diff --git a/language/japanese_utf-8.php b/language/japanese_utf-8.php index 285c3a132..e07c64dde 100644 --- a/language/japanese_utf-8.php +++ b/language/japanese_utf-8.php @@ -1354,7 +1354,7 @@ 13 => 'ルールは必須項目です。', 14 => 'ルートは必須項目です。', 15 => 'ルールとルートで同じプレースホルダー(@)を定義しなければなりません。', - 16 => 'ルートの先頭にindex.phpを含むことはできません。', + 16 => 'ルートの先頭を "/index.php/" とすることはできません。', 17 => 'データベース操作でエラーが発生しました。', 18 => 'URLルーティングを有効にするには、URLリライトを有効にしてください。', 19 => '', diff --git a/public_html/admin/router.php b/public_html/admin/router.php index 349ce1541..5f37c9d2e 100644 --- a/public_html/admin/router.php +++ b/public_html/admin/router.php @@ -343,9 +343,9 @@ function saveRoute($rid, $method, $rule, $route, $priority) $route = '/' . $route; } - // If a route starts with "/index.php", then make it an error to prevent the script + // If a route starts with "/index.php/", then make it an error to prevent the script // from going an infinite loop - if (stripos($route, '/index.php') === 0) { + if (stripos($route, '/index.php/') === 0) { $messageText = $LANG_ROUTER[16]; } diff --git a/public_html/docs/english/config.html b/public_html/docs/english/config.html index 81c8d22b0..5a8044c24 100644 --- a/public_html/docs/english/config.html +++ b/public_html/docs/english/config.html @@ -2154,7 +2154,8 @@

URL Routing

and @month matches "1" in the rule. Then, all placeholders in the route will be replaced with the matched values. And you will be redirected to "http://yourdomain/directory.php?topic=all&year=2016&month=1".

You don't have to include "/index.php" in a rule.

-

You must not start a route with "/index.php", since this will cause an infinite loop.

+

You must not start a route with "/index.php/", since this will cause an infinite loop. However, you can start + with a route with "/index.php?".

A placeholder starts with @ and an alphabetical letter or letters follow it. Placeholders are case-sensitive.

URL Routing works in the reverse way as well. When you output a URL in your plugin or custom diff --git a/public_html/docs/japanese/config.html b/public_html/docs/japanese/config.html index aa25d7e26..2378621d5 100644 --- a/public_html/docs/japanese/config.html +++ b/public_html/docs/japanese/config.html @@ -1852,7 +1852,7 @@

URLルーティング

プレースホルダーがマッチした値に置き換えられ、"http://yourdomain/directory.php?topic=all&year=2016&month=1" にリダイレクトされます。

ルールの中に"/index.php"を含める必要はありません。

-

無限ループになるので、ルートを "/index.php" で始めないようにしてください。

+

無限ループになるので、ルートの先頭は "/index.php/" にしないでください("/index.php?" は大丈夫です)。

プレースホルダーは@で始まり、アルファベットが続きます。プレースホルダーは大文字・小文字を区別します。

URLルーティングは逆向きにも働きます。自作のプラグインやカスタム関数の中でURLを出力する時に、 COM_buildURL 関数を使い、URLルーティング(admin/router.php)で独自のルールとルートを設定する