diff --git a/config/apache/rewrites/ebooks.conf b/config/apache/rewrites/ebooks.conf index a1b2280c..617cacaf 100644 --- a/config/apache/rewrites/ebooks.conf +++ b/config/apache/rewrites/ebooks.conf @@ -1,16 +1,16 @@ -# Work around some naughty hotlinkers +# Work around some naughty hotlinkers. RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} ^https?://.*medialibrary.it [NC] RewriteRule ^(/ebooks/.+/downloads/|/images/covers/) /images/do-not-hotlink.jpg [R=301,L,NC] -# Redirect cover images with caching sha's to the root image -# We do this because some sites like Google cache the cover image path, so changing it results in lots of 404s +# Redirect cover images with caching SHA's to the root image. +# We do this because some sites like Google cache the cover image path, so changing it results in lots of 404s. RewriteRule ^/images/covers/(.+?)\-[a-z0-9]{8}\-(cover|hero)(@2x)?\.(jpg|avif)$ /images/covers/$1-$2$3.$4 -# Rewrite ebook downloads +# Rewrite ebook downloads. RewriteRule ^/ebooks/(.+?)/download$ /ebooks/download.php?url-path=$1 [QSA] -# Misc ebook rewrites +# Misc ebook rewrites. RewriteRule ^/subjects/([^\./]+?)$ /ebooks/index.php?tags[]=$1 [QSA] RewriteRule ^/ebooks/([^\./]+?)$ /authors/get.php?url-path=$1 [QSA] RewriteRule ^/ebooks/([^\./]+?)/downloads$ /bulk-downloads/get.php?author=$1 [QSA] @@ -25,7 +25,7 @@ RewriteRule ^/ebooks/(.+?)/delete$ /ebooks/delete.php?url-path=$1 [L] RewriteCond expr "tolower(%{REQUEST_METHOD}) =~ /^post$/" RewriteRule ^/ebooks/([^\.]+?)$ /ebooks/post.php?url-path=$1 [L] -# List of specific URL rewrites +# List of specific URL rewrites. RewriteRule ^/contribute/accepted-ebooks/? /contribute/collections-policy [R=301,L] RewriteRule ^/ebooks/aristotle/the-nicomachean-ethics(/?$|/.+?$) /ebooks/aristotle/nicomachean-ethics$1 [R=301,L] RewriteRule ^/ebooks/sir-arthur-conan-doyle(/?$|/.+?$) /ebooks/arthur-conan-doyle$1 [R=301,L] @@ -53,11 +53,12 @@ RewriteRule ^/ebooks/samuel-richardson/clarissa-harlowe(/?$|/.+?$) /eb RewriteRule ^/ebooks/tanizaki-junichiro/short-fiction/iwado-z-tamotsu(/?$|/.+?$) /ebooks/tanizaki-junichiro/short-fiction/ijichi-sumimasa_iwado-z-tamotsu$1 [R=301,L] RewriteRule ^/ebooks/george-bernard-shaw/you-can-never-tell(/?$|/.+?$) /ebooks/george-bernard-shaw/you-never-can-tell$1 [R=301,L] -# Rewrite ebooks taken down due to copyright clarifications +# Rewrite ebooks taken down due to copyright clarifications. RewriteRule ^/ebooks/jules-verne/twenty-thousand-leagues-under-the-seas/f-p-walter.* - [R=451,L] -# Prevent this rule from firing if we're getting a distribution file +# Prevent this rule from firing if we're getting a distribution file. RewriteCond %{REQUEST_FILENAME} !^/ebooks/.+?/downloads/.+$ RewriteCond %{REQUEST_FILENAME} !^/ebooks/.+?/text.*$ RewriteCond %{REQUEST_FILENAME} !^/ebooks/.+?/projects.*$ -RewriteRule ^/ebooks/([^\.]+?)$ /ebooks/get.php?url-path=$1 +# Sometimes links in the wild incorrectly include spaces, so use the `B` flag to return a 404 instead of a 403. +RewriteRule ^/ebooks/([^\.]+?)$ /ebooks/get.php?url-path=$1 [B]