mirror of
https://github.com/standardebooks/web.git
synced 2025-07-13 10:02:02 -04:00
Move Apache rewrites into separate files
This commit is contained in:
parent
b7b63a4be5
commit
b340c55460
8 changed files with 131 additions and 230 deletions
9
config/apache/rewrites/artworks.conf
Normal file
9
config/apache/rewrites/artworks.conf
Normal file
|
@ -0,0 +1,9 @@
|
|||
RewriteRule ^/artworks/([^\./]+?)$ /artists/get.php?artist-url-name=$1 [L]
|
||||
|
||||
RewriteCond expr "tolower(%{REQUEST_METHOD}) =~ /^get$/"
|
||||
RewriteRule ^/artworks/([^/\.]+)/([^/\.]+)$ /artworks/get.php?artist-url-name=$1&artwork-url-name=$2 [L]
|
||||
|
||||
RewriteCond expr "tolower(%{REQUEST_METHOD}) =~ /^post$/"
|
||||
RewriteRule ^/artworks/([^/\.]+)/([^/\.]+)$ /artworks/post.php?artist-url-name=$1&artwork-url-name=$2 [L]
|
||||
|
||||
RewriteRule ^/artworks/([^/\.]+)/([^/\.]+)/edit$ /artworks/edit.php?artist-url-name=$1&artwork-url-name=$2 [L]
|
45
config/apache/rewrites/ebooks.conf
Normal file
45
config/apache/rewrites/ebooks.conf
Normal file
|
@ -0,0 +1,45 @@
|
|||
# Rewrite ebook downloads
|
||||
RewriteRule ^/ebooks/(.+?)/download$ /ebooks/download.php?url-path=$1 [QSA]
|
||||
|
||||
# Misc ebook rewrites
|
||||
RewriteRule ^/subjects/([^\./]+?)$ /ebooks/index.php?tags[]=$1 [QSA]
|
||||
RewriteRule ^/ebooks/([^\./]+?)$ /ebooks/author.php?url-path=$1 [QSA]
|
||||
RewriteRule ^/ebooks/([^\./]+?)/downloads$ /bulk-downloads/get.php?author=$1 [QSA]
|
||||
RewriteRule ^/ebooks/([^\./]+?)/feeds$ /feeds/get.php?author=$1 [QSA]
|
||||
RewriteRule ^/collections/([^\./]+?)$ /collections/get.php?collection=$1 [QSA]
|
||||
RewriteRule ^/collections/([^/]+?)/downloads$ /bulk-downloads/get.php?collection=$1
|
||||
RewriteRule ^/collections/([^/]+?)/feeds$ /feeds/get.php?collection=$1
|
||||
|
||||
# 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]
|
||||
RewriteRule ^/ebooks/benjamin-disraeli/sibyl(/?$|/.+?$) /ebooks/benjamin-disraeli/sybil$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/nikolai-gogol/short-fiction/claud-field_isabel-f-hapgood_vizetelly-and-company(/?$|/.+?$) /ebooks/nikolai-gogol/short-fiction/claud-field_isabel-f-hapgood_vizetelly-and-company_george-tolstoy$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/h-g-wells/tales-of-space-and-time(/?$|/.+?$) /ebooks/h-g-wells/short-fiction$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/omar-khayyam/the-rubaiyat-of-omar-khayyam/edward-fitzgerald/edmund-dulac(/?$|/.+?$) /ebooks/omar-khayyam/the-rubaiyat-of-omar-khayyam/edward-fitzgerald$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/alfred-lord-tennyson/idylls-of-the-king/gustave-dore(/?$|/.+?$) /ebooks/alfred-lord-tennyson/idylls-of-the-king$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/w-w-jacobs/the-lady-of-the-barge/maurice-greiffenhagen(/?$|/.+?$) /ebooks/w-w-jacobs/the-lady-of-the-barge$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/robert-louis-stevenson/treasure-island/milo-winter(/?$|/.+?$) /ebooks/robert-louis-stevenson/treasure-island$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/edgar-rice-burroughs/a-princess-of-mars/frank-e-schoonover(/?$|/.+?$) /ebooks/edgar-rice-burroughs/a-princess-of-mars$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/abraham-merritt/the-moon-pool(/?$|/.+?$) /ebooks/a-merritt/the-moon-pool$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/leo-tolstoy/a-confession/aylmer-maude_louise-maude(/?$|/.+?$) /ebooks/leo-tolstoy/a-confession/aylmer-maude$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/f-marion-crawford/khaled-a-tale-of-arabia(/?$|/.+?$) /ebooks/f-marion-crawford/khaled$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/h-rider-haggard/she/maurice-greiffenhagen_charles-h-m-kerr(/?$|/.+?$) /ebooks/h-rider-haggard/she$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/ivan-bunin/short-fiction/s-s-koteliansky_d-h-lawrence_leonard-woolf_bernard-guilbert-guerney_the-russian-review(/?$|/.+?$) /ebooks/ivan-bunin/short-fiction/s-s-koteliansky_d-h-lawrence_leonard-woolf_bernard-guilbert-guerney_the-russian-review_natalie-a-duddington$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/henry-david-thoreau/a-yankee-in-canada(/?$|/.+?$)$ /ebooks/henry-david-thoreau/essays$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/mark-twain/the-autobiography(/?$|/.+?$)$ /ebooks/mark-twain/the-autobiography-of-mark-twain$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/e-nesbit/the-enchanted-castle/h-r-millar(/?$|/.+?$) /ebooks/e-nesbit/the-enchanted-castle$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/epictetus/the-enchiridion/elizabeth-carter(/?$|/.+?$) /ebooks/epictetus/short-works/george-long$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/taras-shevchenko/poetry/alexander-jardine-hunter_ethel-lilian-voynich_paul-selver_florence-randal-livesay(/?$|/.+?$) /ebooks/taras-shevchenko/poetry/alexander-jardine-hunter_ethel-voynich_paul-selver_florence-randal-livesay$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/nikolai-gogol/dead-souls/d-j-hogarth(/?$|/.+?$) /ebooks/nikolai-gogol/dead-souls/c-j-hogarth$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/sigfrid-siwertz/downstream/macmillan-of-canada(/?$|/.+?$) /ebooks/sigfrid-siwertz/downstream/e-classen$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/samuel-richardson/clarissa-harlowe(/?$|/.+?$) /ebooks/samuel-richardson/clarissa$1 [R=301,L]
|
||||
|
||||
# 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
|
||||
RewriteCond %{REQUEST_FILENAME} !^/ebooks/.+?/downloads/.+$
|
||||
RewriteCond %{REQUEST_FILENAME} !^/ebooks/.+?/text.*$
|
||||
RewriteRule ^/ebooks/([^\.]+?)$ /ebooks/ebook.php?url-path=$1
|
10
config/apache/rewrites/feeds.conf
Normal file
10
config/apache/rewrites/feeds.conf
Normal file
|
@ -0,0 +1,10 @@
|
|||
# Redirect old feed URLs
|
||||
RewriteRule ^/(opds|rss|atom)(.*)$ /feeds/$1$2 [R=301,L]
|
||||
|
||||
# If we ask for /opds/all?query=xyz, rewrite that to the search page.
|
||||
RewriteCond %{QUERY_STRING} \bquery=
|
||||
RewriteRule ^/feeds/(opds|atom|rss)/all.xml$ /feeds/$1/search.php [QSA]
|
||||
|
||||
RewriteRule ^/feeds/(atom|rss)/([^/\.]+)$ /feeds/collection.php?type=$1&class=$2
|
||||
|
||||
RewriteRule ^/feeds/(.+\.xml)$ /feeds/download.php?path=$1
|
21
config/apache/rewrites/misc.conf
Normal file
21
config/apache/rewrites/misc.conf
Normal file
|
@ -0,0 +1,21 @@
|
|||
# Favicon rewrites
|
||||
RewriteRule ^/(apple-touch|android-chrome|favicon|mstile|safari-pinned|browserconfig|manifest)([^/]+)$ /images/favicons/$1$2 [L]
|
||||
|
||||
# Redirect tools
|
||||
RewriteRule ^/tools$ https://github.com/standardebooks/tools [R=302,L]
|
||||
|
||||
# Redirect latest version of the manual
|
||||
RewriteRule ^/manual/latest(.*) /manual/index.php?url=$1 [L]
|
||||
|
||||
# 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
|
||||
RewriteRule ^/images/covers/(.+?)\-[a-z0-9]{8}\-(cover|hero)(@2x)?\.(jpg|avif)$ /images/covers/$1-$2$3.$4
|
||||
|
||||
# Rewrite rules for bulk downloads
|
||||
RewriteRule ^/bulk-downloads/(.+\.zip)$ /bulk-downloads/download.php?path=$1
|
||||
RewriteRule ^/bulk-downloads/([^/\.]+)$ /bulk-downloads/collection.php?class=$1
|
3
config/apache/rewrites/newsletters.conf
Normal file
3
config/apache/rewrites/newsletters.conf
Normal file
|
@ -0,0 +1,3 @@
|
|||
RewriteRule ^/newsletter$ /newsletter/subscriptions/new.php [L]
|
||||
RewriteRule ^/newsletter/subscriptions/([^/\.]+?)$ /newsletter/subscriptions/get.php?uuid=$1 [L]
|
||||
RewriteRule ^/newsletter/subscriptions/([^/\.]+?)/(confirm|delete)$ /newsletter/subscriptions/$2.php?uuid=$1 [L]
|
9
config/apache/rewrites/polls.conf
Normal file
9
config/apache/rewrites/polls.conf
Normal file
|
@ -0,0 +1,9 @@
|
|||
RewriteRule ^/polls/([^/\.]+)$ /polls/get.php?pollurlname=$1 [L]
|
||||
RewriteRule ^/polls/([^/\.]+)/votes/new$ /polls/votes/new.php?pollurlname=$1 [L]
|
||||
RewriteRule ^/polls/([^/\.]+)/votes/([0-9]+)$ /polls/votes/get.php?pollurlname=$1&userid=$2 [L]
|
||||
|
||||
RewriteCond expr "tolower(%{REQUEST_METHOD}) =~ /^get$/"
|
||||
RewriteRule ^/polls/([^/\.]+)/votes$ /polls/votes/index.php?pollurlname=$1 [L]
|
||||
|
||||
RewriteCond expr "tolower(%{REQUEST_METHOD}) =~ /^post$/"
|
||||
RewriteRule ^/polls/([^/\.]+)/votes$ /polls/votes/post.php?pollurlname=$1 [L]
|
|
@ -50,7 +50,8 @@ SSLStaplingResponderTimeout 5
|
|||
SSLStaplingReturnResponderErrors off
|
||||
|
||||
Define domain standardebooks.org
|
||||
Define webroot /standardebooks.org/web
|
||||
Define web_root /standardebooks.org/web
|
||||
Define conf_rewrite_root ${web_root}/config/apache/rewrites
|
||||
|
||||
<VirtualHost *:80>
|
||||
ServerName standardebooks.com
|
||||
|
@ -78,7 +79,7 @@ Define webroot /standardebooks.org/web
|
|||
<VirtualHost *:443>
|
||||
ServerName ${domain}
|
||||
ServerAlias www.${domain}
|
||||
DocumentRoot ${webroot}/www
|
||||
DocumentRoot ${web_root}/www
|
||||
ErrorDocument 404 /404
|
||||
ErrorDocument 451 /451
|
||||
ErrorLog /var/log/local/www-error.log
|
||||
|
@ -92,7 +93,7 @@ Define webroot /standardebooks.org/web
|
|||
Header always set Strict-Transport-Security "max-age=15768000"
|
||||
Header set Content-Security-Policy "default-src 'self';"
|
||||
|
||||
<Directory "${webroot}/www/">
|
||||
<Directory "${web_root}/www/">
|
||||
# Disable .htaccess files
|
||||
AllowOverride none
|
||||
|
||||
|
@ -209,131 +210,32 @@ Define webroot /standardebooks.org/web
|
|||
RewriteRule ^(.*)/r/n[\ ]?(.*)$ $1$2 [R=301,N]
|
||||
RewriteRule ^(.*)/[rn]$ $1 [R=301,N]
|
||||
|
||||
# Favicon rewrites
|
||||
RewriteRule ^/(apple-touch|android-chrome|favicon|mstile|safari-pinned|browserconfig|manifest)([^/]+)$ /images/favicons/$1$2 [L]
|
||||
|
||||
# Redirect tools
|
||||
RewriteRule ^/tools$ https://github.com/standardebooks/tools [R=302,L]
|
||||
|
||||
# Redirect latest version of the manual
|
||||
RewriteRule ^/manual/latest(.*) /manual/index.php?url=$1 [L]
|
||||
|
||||
# Rewrite ebook downloads
|
||||
RewriteRule ^/ebooks/(.+?)/download$ /ebooks/download.php?url-path=$1 [QSA]
|
||||
|
||||
# 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]
|
||||
|
||||
# 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]
|
||||
RewriteRule ^/ebooks/benjamin-disraeli/sibyl(/?$|/.+?$) /ebooks/benjamin-disraeli/sybil$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/nikolai-gogol/short-fiction/claud-field_isabel-f-hapgood_vizetelly-and-company(/?$|/.+?$) /ebooks/nikolai-gogol/short-fiction/claud-field_isabel-f-hapgood_vizetelly-and-company_george-tolstoy$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/h-g-wells/tales-of-space-and-time(/?$|/.+?$) /ebooks/h-g-wells/short-fiction$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/omar-khayyam/the-rubaiyat-of-omar-khayyam/edward-fitzgerald/edmund-dulac(/?$|/.+?$) /ebooks/omar-khayyam/the-rubaiyat-of-omar-khayyam/edward-fitzgerald$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/alfred-lord-tennyson/idylls-of-the-king/gustave-dore(/?$|/.+?$) /ebooks/alfred-lord-tennyson/idylls-of-the-king$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/w-w-jacobs/the-lady-of-the-barge/maurice-greiffenhagen(/?$|/.+?$) /ebooks/w-w-jacobs/the-lady-of-the-barge$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/robert-louis-stevenson/treasure-island/milo-winter(/?$|/.+?$) /ebooks/robert-louis-stevenson/treasure-island$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/edgar-rice-burroughs/a-princess-of-mars/frank-e-schoonover(/?$|/.+?$) /ebooks/edgar-rice-burroughs/a-princess-of-mars$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/abraham-merritt/the-moon-pool(/?$|/.+?$) /ebooks/a-merritt/the-moon-pool$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/leo-tolstoy/a-confession/aylmer-maude_louise-maude(/?$|/.+?$) /ebooks/leo-tolstoy/a-confession/aylmer-maude$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/f-marion-crawford/khaled-a-tale-of-arabia(/?$|/.+?$) /ebooks/f-marion-crawford/khaled$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/h-rider-haggard/she/maurice-greiffenhagen_charles-h-m-kerr(/?$|/.+?$) /ebooks/h-rider-haggard/she$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/ivan-bunin/short-fiction/s-s-koteliansky_d-h-lawrence_leonard-woolf_bernard-guilbert-guerney_the-russian-review(/?$|/.+?$) /ebooks/ivan-bunin/short-fiction/s-s-koteliansky_d-h-lawrence_leonard-woolf_bernard-guilbert-guerney_the-russian-review_natalie-a-duddington$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/henry-david-thoreau/a-yankee-in-canada(/?$|/.+?$)$ /ebooks/henry-david-thoreau/essays$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/mark-twain/the-autobiography(/?$|/.+?$)$ /ebooks/mark-twain/the-autobiography-of-mark-twain$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/e-nesbit/the-enchanted-castle/h-r-millar(/?$|/.+?$) /ebooks/e-nesbit/the-enchanted-castle$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/epictetus/the-enchiridion/elizabeth-carter(/?$|/.+?$) /ebooks/epictetus/short-works/george-long$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/taras-shevchenko/poetry/alexander-jardine-hunter_ethel-lilian-voynich_paul-selver_florence-randal-livesay(/?$|/.+?$) /ebooks/taras-shevchenko/poetry/alexander-jardine-hunter_ethel-voynich_paul-selver_florence-randal-livesay$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/nikolai-gogol/dead-souls/d-j-hogarth(/?$|/.+?$) /ebooks/nikolai-gogol/dead-souls/c-j-hogarth$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/sigfrid-siwertz/downstream/macmillan-of-canada(/?$|/.+?$) /ebooks/sigfrid-siwertz/downstream/e-classen$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/samuel-richardson/clarissa-harlowe(/?$|/.+?$) /ebooks/samuel-richardson/clarissa$1 [R=301,L]
|
||||
|
||||
# Rewrite ebooks taken down due to copyright clarifications
|
||||
RewriteRule ^/ebooks/jules-verne/twenty-thousand-leagues-under-the-seas/f-p-walter.* - [R=451,L]
|
||||
|
||||
# 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
|
||||
|
||||
RewriteRule ^/ebooks/([^\./]+?)$ /ebooks/author.php?url-path=$1 [QSA]
|
||||
RewriteRule ^/ebooks/([^\./]+?)/downloads$ /bulk-downloads/get.php?author=$1 [QSA]
|
||||
RewriteRule ^/ebooks/([^\./]+?)/feeds$ /feeds/get.php?author=$1 [QSA]
|
||||
RewriteRule ^/subjects/([^\./]+?)$ /ebooks/index.php?tags[]=$1 [QSA]
|
||||
RewriteRule ^/collections/([^\./]+?)$ /collections/get.php?collection=$1 [QSA]
|
||||
RewriteRule ^/collections/([^/]+?)/downloads$ /bulk-downloads/get.php?collection=$1
|
||||
RewriteRule ^/collections/([^/]+?)/feeds$ /feeds/get.php?collection=$1
|
||||
|
||||
# Prevent this rule from firing if we're getting a distribution file
|
||||
RewriteCond %{REQUEST_FILENAME} !^/ebooks/.+?/downloads/.+$
|
||||
RewriteCond %{REQUEST_FILENAME} !^/ebooks/.+?/text.*$
|
||||
RewriteRule ^/ebooks/([^\.]+?)$ /ebooks/ebook.php?url-path=$1
|
||||
|
||||
# Newsletter
|
||||
RewriteRule ^/newsletter$ /newsletter/subscriptions/new.php [L]
|
||||
RewriteRule ^/newsletter/subscriptions/([^/\.]+?)$ /newsletter/subscriptions/get.php?uuid=$1 [L]
|
||||
RewriteRule ^/newsletter/subscriptions/([^/\.]+?)/(confirm|delete)$ /newsletter/subscriptions/$2.php?uuid=$1 [L]
|
||||
|
||||
# Polls
|
||||
RewriteRule ^/polls/([^/\.]+)$ /polls/get.php?pollurlname=$1 [L]
|
||||
RewriteRule ^/polls/([^/\.]+)/votes/new$ /polls/votes/new.php?pollurlname=$1 [L]
|
||||
RewriteRule ^/polls/([^/\.]+)/votes/([0-9]+)$ /polls/votes/get.php?pollurlname=$1&userid=$2 [L]
|
||||
|
||||
RewriteCond expr "tolower(%{REQUEST_METHOD}) =~ /^get$/"
|
||||
RewriteRule ^/polls/([^/\.]+)/votes$ /polls/votes/index.php?pollurlname=$1 [L]
|
||||
|
||||
RewriteCond expr "tolower(%{REQUEST_METHOD}) =~ /^post$/"
|
||||
RewriteRule ^/polls/([^/\.]+)/votes$ /polls/votes/post.php?pollurlname=$1 [L]
|
||||
|
||||
# Rewrite rules for feeds eeds
|
||||
# Redirect old feed URLs
|
||||
RewriteRule ^/(opds|rss|atom)(.*)$ /feeds/$1$2 [R=301,L]
|
||||
|
||||
# If we ask for /opds/all?query=xyz, rewrite that to the search page.
|
||||
RewriteCond %{QUERY_STRING} \bquery=
|
||||
RewriteRule ^/feeds/(opds|atom|rss)/all.xml$ /feeds/$1/search.php [QSA]
|
||||
|
||||
RewriteRule ^/feeds/(atom|rss)/([^/\.]+)$ /feeds/collection.php?type=$1&class=$2
|
||||
|
||||
RewriteRule ^/feeds/(.+\.xml)$ /feeds/download.php?path=$1
|
||||
|
||||
# Rewrite rules for bulk downloads
|
||||
RewriteRule ^/bulk-downloads/(.+\.zip)$ /bulk-downloads/download.php?path=$1
|
||||
RewriteRule ^/bulk-downloads/([^/\.]+)$ /bulk-downloads/collection.php?class=$1
|
||||
|
||||
# Rewrite rules for cover art
|
||||
RewriteRule ^/artworks/([^\./]+?)$ /artists/get.php?artist-url-name=$1 [L]
|
||||
|
||||
RewriteCond expr "tolower(%{REQUEST_METHOD}) =~ /^get$/"
|
||||
RewriteRule ^/artworks/([^/\.]+)/([^/\.]+)$ /artworks/get.php?artist-url-name=$1&artwork-url-name=$2 [L]
|
||||
|
||||
RewriteCond expr "tolower(%{REQUEST_METHOD}) =~ /^post$/"
|
||||
RewriteRule ^/artworks/([^/\.]+)/([^/\.]+)$ /artworks/post.php?artist-url-name=$1&artwork-url-name=$2 [L]
|
||||
|
||||
RewriteRule ^/artworks/([^/\.]+)/([^/\.]+)/edit$ /artworks/edit.php?artist-url-name=$1&artwork-url-name=$2 [L]
|
||||
Include ${conf_rewrite_root}/misc.conf
|
||||
Include ${conf_rewrite_root}/feeds.conf
|
||||
Include ${conf_rewrite_root}/ebooks.conf
|
||||
Include ${conf_rewrite_root}/newsletters.conf
|
||||
Include ${conf_rewrite_root}/artworks.conf
|
||||
Include ${conf_rewrite_root}/polls.conf
|
||||
|
||||
# Specific config for /ebooks/<author>/<ebook>/downloads
|
||||
<DirectoryMatch "^${webroot}/www/ebooks/.+">
|
||||
<DirectoryMatch "^${web_root}/www/ebooks/.+">
|
||||
# Both directives are required
|
||||
XSendFile on
|
||||
XSendFilePath ${webroot}/www/ebooks
|
||||
XSendFilePath ${web_root}/www/ebooks
|
||||
</DirectoryMatch>
|
||||
|
||||
# Specific config for /bulk-downloads
|
||||
<DirectoryMatch "^${webroot}/www/bulk-downloads/">
|
||||
<DirectoryMatch "^${web_root}/www/bulk-downloads/">
|
||||
# Both directives are required
|
||||
XSendFile on
|
||||
XSendFilePath ${webroot}/www/bulk-downloads
|
||||
XSendFilePath ${web_root}/www/bulk-downloads
|
||||
</DirectoryMatch>
|
||||
|
||||
# Specific config for /feeds
|
||||
<DirectoryMatch "^${webroot}/www/feeds/">
|
||||
<DirectoryMatch "^${web_root}/www/feeds/">
|
||||
# This must be defined at the top level /feeds/ directory
|
||||
# Both directives are required
|
||||
XSendFile on
|
||||
XSendFilePath ${webroot}/www/feeds
|
||||
XSendFilePath ${web_root}/www/feeds
|
||||
</DirectoryMatch>
|
||||
</VirtualHost>
|
||||
|
|
|
@ -50,7 +50,8 @@ SSLStaplingResponderTimeout 5
|
|||
SSLStaplingReturnResponderErrors off
|
||||
|
||||
Define domain standardebooks.test
|
||||
Define webroot /standardebooks.org/web
|
||||
Define web_root /standardebooks.org/web
|
||||
Define conf_rewrite_root ${web_root}/config/apache/rewrites
|
||||
|
||||
<VirtualHost *:80>
|
||||
ServerName ${domain}
|
||||
|
@ -61,7 +62,7 @@ Define webroot /standardebooks.org/web
|
|||
<VirtualHost *:443>
|
||||
ServerName ${domain}
|
||||
ServerAlias www.${domain}
|
||||
DocumentRoot ${webroot}/www
|
||||
DocumentRoot ${web_root}/www
|
||||
ErrorDocument 404 /404
|
||||
ErrorDocument 451 /451
|
||||
ErrorLog /var/log/local/www-error.log
|
||||
|
@ -69,12 +70,12 @@ Define webroot /standardebooks.org/web
|
|||
RewriteEngine on
|
||||
|
||||
SSLEngine on
|
||||
SSLCertificateFile ${webroot}/config/ssl/${domain}.crt
|
||||
SSLCertificateKeyFile ${webroot}/config/ssl/${domain}.key
|
||||
SSLCertificateFile ${web_root}/config/ssl/${domain}.crt
|
||||
SSLCertificateKeyFile ${web_root}/config/ssl/${domain}.key
|
||||
Header always set Strict-Transport-Security "max-age=15768000"
|
||||
Header set Content-Security-Policy "default-src 'self';"
|
||||
|
||||
<Directory "${webroot}/www/">
|
||||
<Directory "${web_root}/www/">
|
||||
# Disable .htaccess files
|
||||
AllowOverride none
|
||||
|
||||
|
@ -191,131 +192,32 @@ Define webroot /standardebooks.org/web
|
|||
RewriteRule ^(.*)/r/n[\ ]?(.*)$ $1$2 [R=301,N]
|
||||
RewriteRule ^(.*)/[rn]$ $1 [R=301,N]
|
||||
|
||||
# Favicon rewrites
|
||||
RewriteRule ^/(apple-touch|android-chrome|favicon|mstile|safari-pinned|browserconfig|manifest)([^/]+)$ /images/favicons/$1$2 [L]
|
||||
|
||||
# Redirect tools
|
||||
RewriteRule ^/tools$ https://github.com/standardebooks/tools [R=302,L]
|
||||
|
||||
# Redirect latest version of the manual
|
||||
RewriteRule ^/manual/latest(.*) /manual/index.php?url=$1 [L]
|
||||
|
||||
# Rewrite ebook downloads
|
||||
RewriteRule ^/ebooks/(.+?)/download$ /ebooks/download.php?url-path=$1 [QSA]
|
||||
|
||||
# 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]
|
||||
|
||||
# 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]
|
||||
RewriteRule ^/ebooks/benjamin-disraeli/sibyl(/?$|/.+?$) /ebooks/benjamin-disraeli/sybil$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/nikolai-gogol/short-fiction/claud-field_isabel-f-hapgood_vizetelly-and-company(/?$|/.+?$) /ebooks/nikolai-gogol/short-fiction/claud-field_isabel-f-hapgood_vizetelly-and-company_george-tolstoy$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/h-g-wells/tales-of-space-and-time(/?$|/.+?$) /ebooks/h-g-wells/short-fiction$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/omar-khayyam/the-rubaiyat-of-omar-khayyam/edward-fitzgerald/edmund-dulac(/?$|/.+?$) /ebooks/omar-khayyam/the-rubaiyat-of-omar-khayyam/edward-fitzgerald$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/alfred-lord-tennyson/idylls-of-the-king/gustave-dore(/?$|/.+?$) /ebooks/alfred-lord-tennyson/idylls-of-the-king$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/w-w-jacobs/the-lady-of-the-barge/maurice-greiffenhagen(/?$|/.+?$) /ebooks/w-w-jacobs/the-lady-of-the-barge$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/robert-louis-stevenson/treasure-island/milo-winter(/?$|/.+?$) /ebooks/robert-louis-stevenson/treasure-island$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/edgar-rice-burroughs/a-princess-of-mars/frank-e-schoonover(/?$|/.+?$) /ebooks/edgar-rice-burroughs/a-princess-of-mars$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/abraham-merritt/the-moon-pool(/?$|/.+?$) /ebooks/a-merritt/the-moon-pool$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/leo-tolstoy/a-confession/aylmer-maude_louise-maude(/?$|/.+?$) /ebooks/leo-tolstoy/a-confession/aylmer-maude$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/f-marion-crawford/khaled-a-tale-of-arabia(/?$|/.+?$) /ebooks/f-marion-crawford/khaled$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/h-rider-haggard/she/maurice-greiffenhagen_charles-h-m-kerr(/?$|/.+?$) /ebooks/h-rider-haggard/she$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/ivan-bunin/short-fiction/s-s-koteliansky_d-h-lawrence_leonard-woolf_bernard-guilbert-guerney_the-russian-review(/?$|/.+?$) /ebooks/ivan-bunin/short-fiction/s-s-koteliansky_d-h-lawrence_leonard-woolf_bernard-guilbert-guerney_the-russian-review_natalie-a-duddington$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/henry-david-thoreau/a-yankee-in-canada(/?$|/.+?$)$ /ebooks/henry-david-thoreau/essays$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/mark-twain/the-autobiography(/?$|/.+?$)$ /ebooks/mark-twain/the-autobiography-of-mark-twain$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/e-nesbit/the-enchanted-castle/h-r-millar(/?$|/.+?$) /ebooks/e-nesbit/the-enchanted-castle$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/epictetus/the-enchiridion/elizabeth-carter(/?$|/.+?$) /ebooks/epictetus/short-works/george-long$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/taras-shevchenko/poetry/alexander-jardine-hunter_ethel-lilian-voynich_paul-selver_florence-randal-livesay(/?$|/.+?$) /ebooks/taras-shevchenko/poetry/alexander-jardine-hunter_ethel-voynich_paul-selver_florence-randal-livesay$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/nikolai-gogol/dead-souls/d-j-hogarth(/?$|/.+?$) /ebooks/nikolai-gogol/dead-souls/c-j-hogarth$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/sigfrid-siwertz/downstream/macmillan-of-canada(/?$|/.+?$) /ebooks/sigfrid-siwertz/downstream/e-classen$1 [R=301,L]
|
||||
RewriteRule ^/ebooks/samuel-richardson/clarissa-harlowe(/?$|/.+?$) /ebooks/samuel-richardson/clarissa$1 [R=301,L]
|
||||
|
||||
# Rewrite ebooks taken down due to copyright clarifications
|
||||
RewriteRule ^/ebooks/jules-verne/twenty-thousand-leagues-under-the-seas/f-p-walter.* - [R=451,L]
|
||||
|
||||
# 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
|
||||
|
||||
RewriteRule ^/ebooks/([^\./]+?)$ /ebooks/author.php?url-path=$1 [QSA]
|
||||
RewriteRule ^/ebooks/([^\./]+?)/downloads$ /bulk-downloads/get.php?author=$1 [QSA]
|
||||
RewriteRule ^/ebooks/([^\./]+?)/feeds$ /feeds/get.php?author=$1 [QSA]
|
||||
RewriteRule ^/subjects/([^\./]+?)$ /ebooks/index.php?tags[]=$1 [QSA]
|
||||
RewriteRule ^/collections/([^\./]+?)$ /collections/get.php?collection=$1 [QSA]
|
||||
RewriteRule ^/collections/([^/]+?)/downloads$ /bulk-downloads/get.php?collection=$1
|
||||
RewriteRule ^/collections/([^/]+?)/feeds$ /feeds/get.php?collection=$1
|
||||
|
||||
# Prevent this rule from firing if we're getting a distribution file
|
||||
RewriteCond %{REQUEST_FILENAME} !^/ebooks/.+?/downloads/.+$
|
||||
RewriteCond %{REQUEST_FILENAME} !^/ebooks/.+?/text.*$
|
||||
RewriteRule ^/ebooks/([^\.]+?)$ /ebooks/ebook.php?url-path=$1
|
||||
|
||||
# Newsletter
|
||||
RewriteRule ^/newsletter$ /newsletter/subscriptions/new.php [L]
|
||||
RewriteRule ^/newsletter/subscriptions/([^/\.]+?)$ /newsletter/subscriptions/get.php?uuid=$1 [L]
|
||||
RewriteRule ^/newsletter/subscriptions/([^/\.]+?)/(confirm|delete)$ /newsletter/subscriptions/$2.php?uuid=$1 [L]
|
||||
|
||||
# Polls
|
||||
RewriteRule ^/polls/([^/\.]+)$ /polls/get.php?pollurlname=$1 [L]
|
||||
RewriteRule ^/polls/([^/\.]+)/votes/new$ /polls/votes/new.php?pollurlname=$1 [L]
|
||||
RewriteRule ^/polls/([^/\.]+)/votes/([0-9]+)$ /polls/votes/get.php?pollurlname=$1&userid=$2 [L]
|
||||
|
||||
RewriteCond expr "tolower(%{REQUEST_METHOD}) =~ /^get$/"
|
||||
RewriteRule ^/polls/([^/\.]+)/votes$ /polls/votes/index.php?pollurlname=$1 [L]
|
||||
|
||||
RewriteCond expr "tolower(%{REQUEST_METHOD}) =~ /^post$/"
|
||||
RewriteRule ^/polls/([^/\.]+)/votes$ /polls/votes/post.php?pollurlname=$1 [L]
|
||||
|
||||
# Rewrite rules for feeds eeds
|
||||
# Redirect old feed URLs
|
||||
RewriteRule ^/(opds|rss|atom)(.*)$ /feeds/$1$2 [R=301,L]
|
||||
|
||||
# If we ask for /opds/all?query=xyz, rewrite that to the search page.
|
||||
RewriteCond %{QUERY_STRING} \bquery=
|
||||
RewriteRule ^/feeds/(opds|atom|rss)/all.xml$ /feeds/$1/search.php [QSA]
|
||||
|
||||
RewriteRule ^/feeds/(atom|rss)/([^/\.]+)$ /feeds/collection.php?type=$1&class=$2
|
||||
|
||||
RewriteRule ^/feeds/(.+\.xml)$ /feeds/download.php?path=$1
|
||||
|
||||
# Rewrite rules for bulk downloads
|
||||
RewriteRule ^/bulk-downloads/(.+\.zip)$ /bulk-downloads/download.php?path=$1
|
||||
RewriteRule ^/bulk-downloads/([^/\.]+)$ /bulk-downloads/collection.php?class=$1
|
||||
|
||||
# Rewrite rules for cover art
|
||||
RewriteRule ^/artworks/([^\./]+?)$ /artists/get.php?artist-url-name=$1 [L]
|
||||
|
||||
RewriteCond expr "tolower(%{REQUEST_METHOD}) =~ /^get$/"
|
||||
RewriteRule ^/artworks/([^/\.]+)/([^/\.]+)$ /artworks/get.php?artist-url-name=$1&artwork-url-name=$2 [L]
|
||||
|
||||
RewriteCond expr "tolower(%{REQUEST_METHOD}) =~ /^post$/"
|
||||
RewriteRule ^/artworks/([^/\.]+)/([^/\.]+)$ /artworks/post.php?artist-url-name=$1&artwork-url-name=$2 [L]
|
||||
|
||||
RewriteRule ^/artworks/([^/\.]+)/([^/\.]+)/edit$ /artworks/edit.php?artist-url-name=$1&artwork-url-name=$2 [L]
|
||||
Include ${conf_rewrite_root}/misc.conf
|
||||
Include ${conf_rewrite_root}/feeds.conf
|
||||
Include ${conf_rewrite_root}/ebooks.conf
|
||||
Include ${conf_rewrite_root}/newsletters.conf
|
||||
Include ${conf_rewrite_root}/artworks.conf
|
||||
Include ${conf_rewrite_root}/polls.conf
|
||||
|
||||
# Specific config for /ebooks/<author>/<ebook>/downloads
|
||||
<DirectoryMatch "^${webroot}/www/ebooks/.+">
|
||||
<DirectoryMatch "^${web_root}/www/ebooks/.+">
|
||||
# Both directives are required
|
||||
XSendFile on
|
||||
XSendFilePath ${webroot}/www/ebooks
|
||||
XSendFilePath ${web_root}/www/ebooks
|
||||
</DirectoryMatch>
|
||||
|
||||
# Specific config for /bulk-downloads
|
||||
<DirectoryMatch "^${webroot}/www/bulk-downloads/">
|
||||
<DirectoryMatch "^${web_root}/www/bulk-downloads/">
|
||||
# Both directives are required
|
||||
XSendFile on
|
||||
XSendFilePath ${webroot}/www/bulk-downloads
|
||||
XSendFilePath ${web_root}/www/bulk-downloads
|
||||
</DirectoryMatch>
|
||||
|
||||
# Specific config for /feeds
|
||||
<DirectoryMatch "^${webroot}/www/feeds/">
|
||||
<DirectoryMatch "^${web_root}/www/feeds/">
|
||||
# This must be defined at the top level /feeds/ directory
|
||||
# Both directives are required
|
||||
XSendFile on
|
||||
XSendFilePath ${webroot}/www/feeds
|
||||
XSendFilePath ${web_root}/www/feeds
|
||||
</DirectoryMatch>
|
||||
</VirtualHost>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue