diff --git a/40-PicoSearch.php b/40-PicoSearch.php index b64f5a2..06d8d3f 100644 --- a/40-PicoSearch.php +++ b/40-PicoSearch.php @@ -27,6 +27,12 @@ class PicoSearch extends AbstractPicoPlugin */ public function onRequestUrl(&$url) { + // If form was submitted without being intercepted by JavaScript, redirect to the canonical search URL. + if (preg_match('/^(.+\/)?search$/', $url) && $_GET['q']) { + header('Location: ' . $this->getPico()->getBaseUrl() . $url . '/' . urlencode($_GET['q'])); + exit; + } + if (preg_match('/^(.+\/)?search\/([^\/]+)(\/.+)?$/', $url, $matches)) { $this->search_terms = urldecode($matches[2]); diff --git a/README.md b/README.md index 54cc995..c4b5d15 100644 --- a/README.md +++ b/README.md @@ -45,12 +45,13 @@ How to design your search form is up to you, but here's a very rudimentary examp template file or on a specific page. ```html -