All pastes #442647 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-04-16 11:57 UTC
rendered paste body
I would like to write a mod_rewrite rule  which would allow me to redirect any URL without a trailing '/' to a certain URL. I would also like to store the everything after the final '/' as a variable which i can pass on to my pre-defined URL. I am having some difficulty getting the regular expression to work and was hoping someone more experienced may be able to help.

so 
/foo/bar/blarn                     would match and $1 would = blarn
/foo/bar/blarn/sneh                would match and $1 would = sneh
/foo                               would match and $1 would = foo
/foo/bar/blarn/                    would not match and would continue to be matched against other             
                                   rules

So far i have tried a lot of combinations.
This works if i add the extension .xhtml
RewriteRule \/([a-z]*)\.xhtml$

however i would like to detect the absence of any trailing characters so i tried a negative look ahead assertion
RewriteRule \/([a-z]*)?!\/$

This compiles, but doesn't achieve the desired results. 
Any ideas ?