A weird request, but I really need this answered. Can you guys help me using re-write rules to remove the trailing slash from urls in Lighttpd.conf?

EG:

**A** www.example.com/page/
**B** www.example.com/page

I want url A to be forced into the semantics of url B.

Thank you very much.

link|improve this question

46% accept rate
feedback

2 Answers

What you are trying to do sounds wrong. The web-server does not handle the request urls that the browser sees. This is an application issue. Your web-application needs to present the urls in the form of www.example.com/page instead of www.example.com/page/ that it does now.

If you do not want to change the application but still want this desired behaviour, you may want to consider using a filtering proxy in front of lighty and then filtering all the returned links.

link|improve this answer
feedback

Not really to the point, but you might want to have the reverse effect...

Anyways, as far as lighttpd code goes, that would be something like this:

url.redirect = ( "/page/" => "/page" )
url.rewrite-once = ( "/page" => "/page/" )

but, since "/page" doesn't find a file and tries the directory "/page/" (and the rewrite seems to do nothing to hide that), that does produce a redirect-loop.

Then your real question would be: is it possible to tell lighttpd not to redirect on directories? That, unfortunately, I didn't find a way to do... but I didn't search in deep, in fact I do prefer URLs with trailing slashes (also visually)...

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.