diff --git a/ChangeLog.md b/ChangeLog.md
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -1,3 +1,7 @@
+## 3.0.0.6
+
+Fix trailing slashes for `UrlMap` and other non-root setups [#325](https://github.com/yesodweb/wai/issues/325)
+
 ## 3.0.0.4
 
 Add missing trailing slashes [#312](https://github.com/yesodweb/wai/issues/312)
diff --git a/Network/Wai/Application/Static.hs b/Network/Wai/Application/Static.hs
--- a/Network/Wai/Application/Static.hs
+++ b/Network/Wai/Application/Static.hs
@@ -52,6 +52,7 @@
 data StaticResponse =
       -- | Just the etag hash or Nothing for no etag hash
       Redirect Pieces (Maybe ByteString)
+    | RawRedirect ByteString
     | NotFound
     | FileResponse File H.ResponseHeaders
     | NotModified
@@ -79,15 +80,15 @@
             let pieces' = setLast pieces index in
             case () of
               () | ssRedirectToIndex -> return $ Redirect pieces' Nothing
-                 | noTrailingSlash pieces, Just trailing <- toPiece ""  ->
-                    return $ Redirect (pieces ++ [trailing]) Nothing
+                 | Just path <- addTrailingSlash req ->
+                    return $ RawRedirect path
                  | otherwise ->
                     -- start the checking process over, with a new set
                     checkPieces ss pieces' req
         Nothing ->
             case ssListing of
-                Just _ | noTrailingSlash pieces, Just trailing <- toPiece "" ->
-                    return $ Redirect (pieces ++ [trailing]) Nothing
+                Just _ | Just path <- addTrailingSlash req ->
+                    return $ RawRedirect path
                 Just listing -> do
                     -- directory listings turned on, display it
                     builder <- listing pieces folder
@@ -104,6 +105,14 @@
         | fromPiece t == "" = [x]
     setLast (a:b) x = a : setLast b x
 
+    addTrailingSlash :: W.Request -> Maybe ByteString
+    addTrailingSlash req
+        | S8.null rp = Just "/"
+        | S8.last rp == '/' = Nothing
+        | otherwise = Just $ S8.snoc rp '/'
+      where
+        rp = W.rawPathInfo req
+
     noTrailingSlash :: Pieces -> Bool
     noTrailingSlash [] = False
     noTrailingSlash [x] = fromPiece x /= ""
@@ -248,6 +257,12 @@
             sendResponse $ W.responseLBS H.status301
                 [ ("Content-Type", "text/plain")
                 , ("Location", S8.append loc $ H.renderQuery True qString)
+                ] "Redirect"
+
+    response (RawRedirect path) =
+            sendResponse $ W.responseLBS H.status301
+                [ ("Content-Type", "text/plain")
+                , ("Location", path)
                 ] "Redirect"
 
     response NotFound = sendResponse $ W.responseLBS H.status404
diff --git a/test/WaiAppStaticTest.hs b/test/WaiAppStaticTest.hs
--- a/test/WaiAppStaticTest.hs
+++ b/test/WaiAppStaticTest.hs
@@ -9,6 +9,7 @@
 import System.PosixCompat.Files (getFileStatus, modificationTime)
 
 import Network.HTTP.Date
+import Network.HTTP.Types (status500)
 {-import System.Locale (defaultTimeLocale)-}
 {-import Data.Time.Format (formatTime)-}
 
@@ -123,3 +124,20 @@
       assertStatus 304 req
       assertNoHeader "Cache-Control" req
 
+    context "301 redirect to add a trailing slash on directories if missing" $ do
+      it "works at the root" $ fileServerApp $ do
+        req <- request (setRawPathInfo defRequest "/a")
+        assertStatus 301 req
+        assertHeader "Location" "/a/" req
+
+      let urlMapApp = flip runSession $ \req send ->
+            case pathInfo req of
+                "subPath":rest ->
+                    let req' = req { pathInfo = rest }
+                     in (staticApp $ defaultFileServerSettings "test") req' send
+                _ -> send $ responseLBS status500 []
+                    "urlMapApp: only works at subPath"
+      it "works with subpath at the root of the file server" $ urlMapApp $ do
+        req <- request (setRawPathInfo defRequest "/subPath")
+        assertStatus 301 req
+        assertHeader "Location" "/subPath/" req
diff --git a/wai-app-static.cabal b/wai-app-static.cabal
--- a/wai-app-static.cabal
+++ b/wai-app-static.cabal
@@ -1,5 +1,5 @@
 name:            wai-app-static
-version:         3.0.0.5
+version:         3.0.0.6
 license:         MIT
 license-file:    LICENSE
 author:          Michael Snoyman <michael@snoyman.com>
