Re: SBBS + PHP and URL paths
By: alterego to All on Wed Aug 12 2020 01:44 pm
Howdy,
I know reading the wiki you can have SBBS call php either via CGI or FPM.
Is there a way to have FPM called, when the suffix is not ending with .php?
EG: Lets say I have a url http://mysite/foo/bar - I actually want a nominated file (let say index.php) to be called with /foo/bar.
So instead of writing the URL as http://mysite/index.php/foo/bar (which works), how can I have http://mysite/foo/bar resolve to index.php being called?
Is it possible?
Yeah, look at wiki.synchro.net. It's a dokuwiki.php served up via Synchronet web server.
(I know I can have nginx doing this - and that might be what I need to do, if I cant get sbbs's web server doing it...)
$ cat webctrl.ini
;Realm=Enter your BBS QWK ID:
PathInfoIndex=yes
JSPreExec=load(js.startup_dir+'/doku_rewrite.js');
Rewrite=doku_rewrite();
[*.php]
FastCGISocket=127.0.0.1:9000
$ cat doku_rewrite.js
function doku_rewrite()
{
var n=http_request.request_string;
// Simple replacements...
n=n.replace(/^([^\?]*\/)_media\/(.*)/,"$1lib/exe/fetch.php?media=$2");
n=n.replace(/^([^\?]*\/)_detail\/(.*)/,"$1lib/exe/detail.php?media=$2");
n=n.replace(/^([^\?]*\/)_export\/([^\/]+)\/(.*)/,"$1doku.php?do=export_$ 2&id=$3");
// This handles adding doku.php to the index bit of the URI
var pi = http_request.path_info;
if (pi[0]=='/') {
pi=pi.substr(1).replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, " \\$&");;
n=n.replace(new RegExp('^(.*)('+pi+'(?:\\?.*)?)$'), "$1doku.php? id=$2");
}
// If the URI ends with a slash, stuff in doku.php at the end.
n=n.replace(/^([^\?]*\/)(\?.*)?$/,"$1doku.php$2");
// index.php becomes doku.php
n=n.replace(/^([^\?]*\/)index.php/,"$1doku.php");
// Handle it.
if (n != http_request.request_string) {
// Replace all but the first '?' with '&'
n=n.replace(/(^.*\?[^\?]*)\?/g,'$1&');
http_request.request_string = n;
return true;
}
return false;
}
If you have questions, best to ask Deuce in #synchronet at irc.synchro.net
digital man
Synchronet "Real Fact" #4:
Synchronet version 3 is written mostly in C, with some C++, x86 ASM, and Pascal.
Norco, CA WX: 68.5øF, 56.0% humidity, 0 mph S wind, 0.00 inches rain/24hrs
---
þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net