aboutsummaryrefslogtreecommitdiff
path: root/doc/forum/missing_pages_redirected_to_search-SOLVED
diff options
context:
space:
mode:
authorhttps://launchpad.net/~eliasson <eliasson@web>2016-01-31 16:07:53 -0400
committeradmin <admin@branchable.com>2016-01-31 16:07:53 -0400
commit4c2b3ff8c3287aaea7a6f19c0cd6186f14ad3c42 (patch)
tree8db3b849df868ca98550eb059bc0ba160a3e4b2c /doc/forum/missing_pages_redirected_to_search-SOLVED
parent28701b02deb0eaa00062406983be62265f3b479d (diff)
downloadikiwiki-4c2b3ff8c3287aaea7a6f19c0cd6186f14ad3c42.tar
ikiwiki-4c2b3ff8c3287aaea7a6f19c0cd6186f14ad3c42.tar.gz
Added a comment
Diffstat (limited to 'doc/forum/missing_pages_redirected_to_search-SOLVED')
-rw-r--r--doc/forum/missing_pages_redirected_to_search-SOLVED/comment_2_bc0291b1afc2e9b4a853c168d3adfd78._comment83
1 files changed, 83 insertions, 0 deletions
diff --git a/doc/forum/missing_pages_redirected_to_search-SOLVED/comment_2_bc0291b1afc2e9b4a853c168d3adfd78._comment b/doc/forum/missing_pages_redirected_to_search-SOLVED/comment_2_bc0291b1afc2e9b4a853c168d3adfd78._comment
new file mode 100644
index 000000000..d170ab421
--- /dev/null
+++ b/doc/forum/missing_pages_redirected_to_search-SOLVED/comment_2_bc0291b1afc2e9b4a853c168d3adfd78._comment
@@ -0,0 +1,83 @@
+[[!comment format=mdwn
+ username="https://launchpad.net/~eliasson"
+ nickname="eliasson"
+ subject="comment 2"
+ date="2016-01-31T20:07:52Z"
+ content="""
+Using Apache 2.4.10 (Debian 8's package) I solved it the following way:
+
+1. In the Apache site configuration, set `ErrorDocument 404` to the ikiwiki.cgi URL path.
+2. Apply the following patch to the plugins search and 404. The easiest and probably cleanest way is to copy the plugins to your `$libdir/IkiWiki/Plugins` and edit them there. It works with xapian omega search but wouldn't work with google, since the *P* CGI parameter is not set (instead, omega uses the `QUERY_STRING` environment variable). Perhaps one day I'll make this a proper patch and submit as a pull request.
+
+[Apache 2.4.13 adds support](https://httpd.apache.org/docs/2.4/mod/core.html#errordocument) for dynamic strings in `ErrorDocument`s, so you could do something similar to the solution for Nginx above. Until that is packaged in your stable Linux distro of choice, this hack can be used.
+
+<pre>
+<code>
+diff --git a/IkiWiki/Plugin/404.pm b/IkiWiki/Plugin/404.pm
+index 42cfa9e..a12fd40 100644
+--- a/IkiWiki/Plugin/404.pm
++++ b/IkiWiki/Plugin/404.pm
+@@ -74,7 +74,9 @@ sub cgi ($) {
+ my $page = cgi_page_from_404(
+ Encode::decode_utf8($ENV{REDIRECT_URL}),
+ $config{url}, $config{usedirs});
+- IkiWiki::Plugin::goto::cgi_goto($cgi, $page);
++
++ $ENV{QUERY_STRING}=\"P=$page\";
++ IkiWiki::Plugin::search::search($cgi);
+ }
+ }
+
+diff --git a/IkiWiki/Plugin/search.pm b/IkiWiki/Plugin/search.pm
+index 24b16fe..24d7b3c 100644
+--- a/IkiWiki/Plugin/search.pm
++++ b/IkiWiki/Plugin/search.pm
+@@ -183,24 +183,31 @@ sub delete (@) {
+ }
+ }
+
++sub search($) {
++ my $cgi=shift;
++
++ if ($config{google_search}) {
++ print $cgi->redirect(\"https://www.google.com/search?sitesearch=$config{url}&q=\".$cgi->param('P'));
++ exit 0;
++ }
++ else {
++ # only works for GET requests
++ chdir(\"$config{wikistatedir}/xapian\") || error(\"chdir: $!\");
++ $ENV{OMEGA_CONFIG_FILE}=\"./omega.conf\";
++ $ENV{CGIURL}=IkiWiki::cgiurl();
++ IkiWiki::loadindex();
++ $ENV{HELPLINK}=htmllink(\"\", \"\", \"ikiwiki/searching\",
++ noimageinline => 1, linktext => \"Help\");
++
++ exec($config{omega_cgi}) || error(\"$config{omega_cgi} failed: $!\");
++ }
++}
++
+ sub cgi ($) {
+ my $cgi=shift;
+
+ if (defined $cgi->param('P')) {
+- if ($config{google_search}) {
+- print $cgi->redirect(\"https://www.google.com/search?sitesearch=$config{url}&q=\".$cgi->param('P'));
+- exit 0;
+- }
+- else {
+- # only works for GET requests
+- chdir(\"$config{wikistatedir}/xapian\") || error(\"chdir: $!\");
+- $ENV{OMEGA_CONFIG_FILE}=\"./omega.conf\";
+- $ENV{CGIURL}=IkiWiki::cgiurl();
+- IkiWiki::loadindex();
+- $ENV{HELPLINK}=htmllink(\"\", \"\", \"ikiwiki/searching\",
+- noimageinline => 1, linktext => \"Help\");
+- exec($config{omega_cgi}) || error(\"$config{omega_cgi} failed: $!\");
+- }
++ search($cgi);
+ }
+ }
+
+</code>
+</pre>
+"""]]