Is it possible to have any missing pages(404's) redirected to the search(omega) ?
So if someone comes to my site with http://example.com/foo_was_here it would result in 'foo_was_here' being passed as a search parameter to omega ? --Mick
DONE
I use nginx instead of apache.
Just add the following to the server block outside of any location block in nginx.conf
You must also make sure you have setup and enabled the search plugin(omega)
error_page 404 /ikiwiki.cgi?P=$uri;
My full nginx.conf
server {
listen [::]:80; #IPv6 capable
server_name www.lunix.com.au;
access_log /var/log/nginx/www.lunix.com.au-access.log main;
error_log /var/log/nginx/www.lunix.com.au-error.log warn;
error_page 404 /ikiwiki.cgi?P=$uri;
location / {
root /home/lunix/public_html/lunix;
index index.html index.htm;
}
location ~ ikiwiki\.cgi$ {
root /home/lunix/public_html/lunix;
include /etc/nginx/fastcgi_params.cgi;
fastcgi_pass 127.0.0.1:9999;
fastcgi_param SCRIPT_FILENAME /home/lunix/public_html/lunix$fastcgi_script_name; # same path as above
}
}
Same can be done for lighttpd via a lua script (said rewrite.lua) using mod_magnet than need to be installed and called in your conf like this :
# error-handler for status 404 $HTTP["url"] =~ "^/mysite/" { magnet.attract-physical-path-to = ( server.document-root + "/rewrite.lua" ) }Ref : mod_magnet docs
function removePrefix(str, prefix) return str:sub(1,#prefix+1) == prefix.."/" and str:sub(#prefix+2) end attr = lighty.stat(lighty.env["physical.path"]) local prefix = '/mysite' if (not attr) then -- we couldn't stat() the file -- let's generate a xapian query with it new_uri =removePrefix(lighty.env["uri.path"], prefix) print ("page not found : " .. new_uri .. " asking xapian") lighty.env["uri.path"] = "/mysite/ikiwiki.cgi" lighty.env["uri.query"] = "P=" .. new_uri lighty.env["physical.rel-path"] = lighty.env["uri.path"] lighty.env["physical.path"] = lighty.env["physical.doc-root"] .. lighty.env["physical.rel-path"] endHope this is useful to you
Using Apache 2.4.10 (Debian 8's package) I solved it the following way:
ErrorDocument 404to the ikiwiki.cgi URL path.$libdir/IkiWiki/Pluginsand 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 theQUERY_STRINGenvironment variable). Perhaps one day I'll make this a proper patch and submit as a pull request.Apache 2.4.13 adds support for dynamic strings in
ErrorDocuments, 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.