diff --git a/ChangeLog.md b/ChangeLog.md
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -1,3 +1,7 @@
+## 3.0.14
+
+* Middleware to force domain names. [#506](https://github.com/yesodweb/wai/issues/506) [#507](https://github.com/yesodweb/wai/pull/507)
+
 ## 3.0.13.1
 
 * Support wai 3.2
diff --git a/Network/Wai/Middleware/ForceDomain.hs b/Network/Wai/Middleware/ForceDomain.hs
new file mode 100644
--- /dev/null
+++ b/Network/Wai/Middleware/ForceDomain.hs
@@ -0,0 +1,38 @@
+-- |
+--
+-- @since 3.0.14
+module Network.Wai.Middleware.ForceDomain where
+
+import Data.ByteString (ByteString)
+import Data.Monoid ((<>), mempty)
+import Network.HTTP.Types (hLocation, methodGet, status301, status307)
+import Prelude
+
+import Network.Wai
+import Network.Wai.Request
+
+-- | Force a domain by redirecting.
+-- The `checkDomain` function takes the current domain and checks whether it is correct.
+-- It should return `Nothing` if the domain is correct, or `Just "domain.com"` if it is incorrect.
+--
+-- @since 3.0.14
+forceDomain :: (ByteString -> Maybe ByteString) -> Middleware
+forceDomain checkDomain app req sendResponse =
+    case requestHeaderHost req >>= checkDomain of
+        Nothing ->
+            app req sendResponse
+        Just domain ->
+            sendResponse $ redirectResponse domain
+
+    where
+        -- From: Network.Wai.Middleware.ForceSSL
+        redirectResponse domain =
+            responseBuilder status [(hLocation, location domain)] mempty
+
+        location h =
+            let p = if appearsSecure req then "https://" else "http://" in
+            p <> h <> rawPathInfo req <> rawQueryString req
+
+        status
+            | requestMethod req == methodGet = status301
+            | otherwise = status307
diff --git a/Network/Wai/Middleware/Gzip.hs b/Network/Wai/Middleware/Gzip.hs
--- a/Network/Wai/Middleware/Gzip.hs
+++ b/Network/Wai/Middleware/Gzip.hs
@@ -65,6 +65,7 @@
         [ "application/json"
         , "application/javascript"
         , "application/ecmascript"
+        , "image/x-icon"
         ]
 
 -- | Use gzip to compress the body of the response.
diff --git a/wai-extra.cabal b/wai-extra.cabal
--- a/wai-extra.cabal
+++ b/wai-extra.cabal
@@ -1,5 +1,5 @@
 Name:                wai-extra
-Version:             3.0.13.1
+Version:             3.0.14
 Synopsis:            Provides some basic WAI handlers and middleware.
 description:
   Provides basic WAI handler and middleware functionality:
@@ -141,6 +141,7 @@
                      Network.Wai.Middleware.Vhost
                      Network.Wai.Middleware.HttpAuth
                      Network.Wai.Middleware.StreamFile
+                     Network.Wai.Middleware.ForceDomain
                      Network.Wai.Middleware.ForceSSL
                      Network.Wai.Middleware.Routed
                      Network.Wai.Parse
