Subject: Code: Using short URL's with lighttpd
Hi
if youre running lighttpd and want to use short urls (mod_rewrite_urls = 1 in the configfile) you have to add the following code to your lighttpd.conf:
ATTENTION The lines in the snippet here are broken so here is the working code:
http://dev.firc.de/wiki/LighttpdUnbShortURL
Notice the variable used here so be sure to run a version of the httpd that supports variables in the configfile.
This is a quick'n'dirty hack for static document-roots only (at least you can copy the rewrite-rules when you are in a virtual hosting-environment)
There is certainly a better way to do short urls with lighttpd but -hey- this works
Cheers,
fireglow
if youre running lighttpd and want to use short urls (mod_rewrite_urls = 1 in the configfile) you have to add the following code to your lighttpd.conf:
# Make the UBN rewrite rules working
## Variable var.unb
## Must contain the path of your UNB-installation relative to your document-root
## (without any slashes neither at the beginning nor at end)
## Example: The URL of your board is http://example.com/forums/(forum.php...etc,etc)
## Then your var.unb would be "forums"
var.unb = "unb"
url.rewrite-once = (
"^/" + unb + "/forum/([0-9]+)[^;]*(;(.*))?" => unb + "/forum.php?req=main&id=$1&rewrite=$3",
"^/" + unb + "/forum(;(.*))?" => unb + "/forum.php?req=main&rewrite=$2",
"^/" + unb + "/thread/([0-9]+),(-?[0-9]+)[^;]*(;(.*))?$" => unb + "/forum.php?req=thread&id=$1&page=$2&rewrite=$4",
"^/" + unb + "/thread/([0-9]+)[^;]*(;(.*))?$" => unb + "/forum.php?req=thread&id=$1&rewrite=$3",
"^/" + unb + "/post/([0-9]+)[^;]*(;(.*))?$" => unb + "/forum.php?req=thread&postid=$1&rewrite=$3",
"^/" + unb + "/user/([0-9]+)[^;]*(;(.*))?$" => unb + "/forum.php?req=cp&id=$1&rewrite=$3",
"^/" + unb + "/search/(.*)" => unb + "/forum.php?req=search&InSubject=1&InMessage=1&Query=$1",
"^/" + unb + "/unread(;(.*))?$" => unb + "/forum.php?req=search&nodef=1&Special=unread&ResultView=1&rewrite=$2",
"^/" + unb + "/new(;(.*))?$" => unb + "/forum.php?req=search&nodef=1&Special=new&ResultView=1rewrite=&$2",
"^/" + unb + "/mytopics(;(.*))?$" => unb + "/forum.php?req=search&nodef=1&Special=mytopics&ResultView=1rewrite=&$2",
"^/" + unb + "/cp(;(.*))?$" => unb + "/forum.php?req=cp&item=1&rewrite=$2",
"^/" + unb + "/users(;(.*))?$" => unb + "/forum.php?req=users&rewrite=$2",
"^/" + unb + "/search(;(.*))?$" => unb + "/forum.php?req=search&rewrite=$2",
"^/" + unb + "/stat(;(.*))?$" => unb + "/forum.php?req=stat&rewrite=$2"
)
## Variable var.unb
## Must contain the path of your UNB-installation relative to your document-root
## (without any slashes neither at the beginning nor at end)
## Example: The URL of your board is http://example.com/forums/(forum.php...etc,etc)
## Then your var.unb would be "forums"
var.unb = "unb"
url.rewrite-once = (
"^/" + unb + "/forum/([0-9]+)[^;]*(;(.*))?" => unb + "/forum.php?req=main&id=$1&rewrite=$3",
"^/" + unb + "/forum(;(.*))?" => unb + "/forum.php?req=main&rewrite=$2",
"^/" + unb + "/thread/([0-9]+),(-?[0-9]+)[^;]*(;(.*))?$" => unb + "/forum.php?req=thread&id=$1&page=$2&rewrite=$4",
"^/" + unb + "/thread/([0-9]+)[^;]*(;(.*))?$" => unb + "/forum.php?req=thread&id=$1&rewrite=$3",
"^/" + unb + "/post/([0-9]+)[^;]*(;(.*))?$" => unb + "/forum.php?req=thread&postid=$1&rewrite=$3",
"^/" + unb + "/user/([0-9]+)[^;]*(;(.*))?$" => unb + "/forum.php?req=cp&id=$1&rewrite=$3",
"^/" + unb + "/search/(.*)" => unb + "/forum.php?req=search&InSubject=1&InMessage=1&Query=$1",
"^/" + unb + "/unread(;(.*))?$" => unb + "/forum.php?req=search&nodef=1&Special=unread&ResultView=1&rewrite=$2",
"^/" + unb + "/new(;(.*))?$" => unb + "/forum.php?req=search&nodef=1&Special=new&ResultView=1rewrite=&$2",
"^/" + unb + "/mytopics(;(.*))?$" => unb + "/forum.php?req=search&nodef=1&Special=mytopics&ResultView=1rewrite=&$2",
"^/" + unb + "/cp(;(.*))?$" => unb + "/forum.php?req=cp&item=1&rewrite=$2",
"^/" + unb + "/users(;(.*))?$" => unb + "/forum.php?req=users&rewrite=$2",
"^/" + unb + "/search(;(.*))?$" => unb + "/forum.php?req=search&rewrite=$2",
"^/" + unb + "/stat(;(.*))?$" => unb + "/forum.php?req=stat&rewrite=$2"
)
ATTENTION The lines in the snippet here are broken so here is the working code:
http://dev.firc.de/wiki/LighttpdUnbShortURL
Notice the variable used here so be sure to run a version of the httpd that supports variables in the configfile.
This is a quick'n'dirty hack for static document-roots only (at least you can copy the rewrite-rules when you are in a virtual hosting-environment)
There is certainly a better way to do short urls with lighttpd but -hey- this works

Cheers,
fireglow
Unless Severus Snape makes an appearance, you won't have me reading any more of this!

fireglow
Show profile
Link to this post
