Not logged in. · Lost password · Register
Forum: Support Installation, update and import RSS
Code: Using short URL's with lighttpd
fireglow #1
Member since Nov 2005 · 12 posts · Location: Germany
Group memberships: Members
Show profile · Link to this post
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:

# 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"
)

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!
This post was edited 2 times, last on 2006-04-15, 16:46 by fireglow.
Edit reason: Typos
fireglow #2
Member since Nov 2005 · 12 posts · Location: Germany
Group memberships: Members
Show profile · Link to this post
Whops, i found two bugs in the code and cant edit my post anymore so please go to http://dev.firc.de/wiki/LighttpdUnbShortURL and get it from there!
Unless Severus Snape makes an appearance, you won't have me reading any more of this!
TimoGoebel #3
Member since Nov 2005 · 20 posts · Location: Germany
Group memberships: Members
Show profile · Link to this post
In reply to post #1
The link seems to be broken. This code works for me:
# 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"
)

Remember to set
server.indexfiles    = ("forum.php")
for UNB to work properly... :-)
TimoGoebel #4
Member since Nov 2005 · 20 posts · Location: Germany
Group memberships: Members
Show profile · Link to this post
Actually, there is another bug i found, but i can't edit my post :-(

So here is, what you need to add:
"^/" + unb + "/search(;(.*))?(\?(.*))?$" => unb + "/forum.php?req=search&rewrite=$2$4",

The problem is, that you also need to take care of query strings. Apache manages them for you...
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Go to forum
This board is powered by the Unclassified NewsBoard software, 20110527-dev, © 2003-2011 by Yves Goergen
Page created in 524 ms (259.2 ms) · 55 database queries in 299.2 ms
Current time: 2012-02-08, 09:28:07 (UTC +01:00)