]> git.donarmstrong.com Git - lilypond.git/blobdiff - Documentation/web/server/lilypond.org.htaccess
issue 4829: add all languages for content negotiation in .htaccess
[lilypond.git] / Documentation / web / server / lilypond.org.htaccess
index 04770bad6bb77778aa4c2856e68cf4a864dec5ed..d6bc37fb5936ebfd6ffefd80f5b8027664e26d09 100644 (file)
 
 RewriteEngine On
 
+# Permanent redirect from www.lilypond.org to lilypond.org
+RewriteCond "%{HTTP_HOST}" "^www\.(.+)$" [NC]
+RewriteRule "^/?(.*)$"     "http://%1/$1" [R=301,L,NE]
+
 # Deny following of symlinks by robots.
 # HTTrack is a known offender.
 # better yet, to redirect this to page that tells adminstrator
@@ -23,6 +27,10 @@ RewriteEngine On
 RewriteCond %{HTTP_USER_AGENT} httrack [NC]
 RewriteRule ^.*/source/.*$ /please-respect-robots.txt.html [L]
 
+# Deny rogue crawler
+RewriteCond %{HTTP_USER_AGENT} ^(.*)AhrefsBot(.*) [NC]
+RewriteRule .* - [F,L]
+
 # Permanent top level entry points -- ./doc
 RedirectMatch ^/music-glossary /glossary
 RedirectMatch ^/tutorial /learning
@@ -33,7 +41,6 @@ RedirectMatch ^/documentation/$ /doc
 #
 RedirectMatch ^/bugs   /bug-reports
 #RedirectMatch ^/bugs  http://code.google.com/p/lilypond/issues/list
-RedirectMatch ^/wiki   http://wiki.lilynet.net
 # the new website already has an /authors
 #RedirectMatch ^/authors /doc/Documentation/topdocs/AUTHORS
 # the new website has news on the main page
@@ -42,14 +49,17 @@ RedirectMatch ^/stable    /doc/stable
 # the new website has a dedicated page for development.
 #RedirectMatch ^/development    /doc/development
 
-#old# default doc dir
-RedirectMatch ^/doc/*$ /doc/v2.12
-# make attempt at `latest' symlink avoid ^v catch-all doc fix rule below
-RedirectMatch ^/doc//*latest/*(.*)$ /doc/v2.13/$1
-RedirectMatch ^/doc//*development/*(.*)$ /doc/v2.13/$1
-RedirectMatch ^/doc//*stable/*(.*)$ /doc/v2.12/$1
-RedirectMatch ^/doc//*([^v].*)$ /doc/v2.12/$1
-RedirectMatch ^(/Documentation.*)$ /doc/v2.12$1
+# Main doc URL redirects
+RedirectMatch ^/doc/?$ /manuals
+RedirectMatch ^/doc/stable/?$ /manuals
+RedirectMatch ^/doc/development/?$ /development
+
+# Allow to use deep links to latest stable or development docs
+RedirectMatch ^/doc//*latest/*(.*)$ /doc/v2.19/$1
+RedirectMatch ^/doc//*development/*(.*)$ /doc/v2.19/$1
+RedirectMatch ^/doc//*stable/*(.*)$ /doc/v2.18/$1
+RedirectMatch ^/doc//*([^v].*)$ /doc/v2.18/$1
+RedirectMatch ^(/Documentation.*)$ /doc/v2.18$1
 RedirectMatch ^/index$ /
 
 # fix root calculation: no double slashes
@@ -57,7 +67,7 @@ RedirectMatch ^/index$ /
 
 ###########################################
 
-## Rewrite all non-existing files at toplevel to the /web/ dir, so our
+## Rewrite all non-existing files at toplevel to the /website/ dir, so our
 ## internal structure for rsync doesn't have to be changed.
 ## This works for the current/old site as well as the new one.
 
@@ -66,7 +76,7 @@ RewriteBase /
 
 SetEnvIf REQUEST_URI .* WEB=/website
 
-# Rewrite empty to /web
+# Rewrite empty to /website
 RewriteCond %{REQUEST_URI} ^/*$
 RewriteRule ^(/*)$ %{ENV:WEB}/ [QSA,L]
 
@@ -76,12 +86,12 @@ RewriteCond %{REQUEST_URI} ^/?[^/]+[.]css$
 RewriteCond %{REQUEST_FILENAME} !-f
 # ...and does not match an existing directory
 RewriteCond %{REQUEST_FILENAME} !-d
-# ...prefix with web
+# ...prefix with website
 RewriteRule ^(.+)$ %{ENV:WEB}/$1 [QSA,L]
 
 # Request without trailing slash
 RewriteCond %{REQUEST_URI} !.*/$
-# ...that would access a directory in /web
+# ...that would access a directory in /website
 RewriteCond %{DOCUMENT_ROOT}%{ENV:WEB}%{REQUEST_URI} -d
 # ...and does not start with /web
 RewriteCond %{REQUEST_URI} !^%{ENV:WEB}
@@ -91,7 +101,7 @@ RewriteCond %{REQUEST_URI} !^/doc$
 # ...add trailing slash for [menu] and to avoid /web/ in browser url
 RewriteRule ^(.+)$ http://%{HTTP_HOST}/$1/ [R,QSA,L]
 
-# Request that does not start with /web
+# Request that does not start with /website
 RewriteCond %{REQUEST_URI} !^/website
 RewriteCond %{REQUEST_URI} !^%{ENV:WEB}
 # ...and does not start with /doc/
@@ -105,6 +115,9 @@ RewriteCond %{REQUEST_FILENAME} !-d
 # ..prefix with /web
 RewriteRule ^(.+)$ %{ENV:WEB}/$1 [QSA,L]
 
+## Redirect the old web/ to the homepage
+RedirectMatch 301 ^/web/.* /
+
 ###########################################
 
 # latin1 version copied to web and doc/2.x
@@ -117,9 +130,18 @@ AddCharset utf-8 .fr
 AddCharset utf-8 .nl
 AddCharset utf-8 .txt
 
-# fix broken auto language selection for Hungarian
+# Add extensions for language negotiation
+# See: https://www.w3.org/International/questions/qa-apache-lang-neg
+AddLanguage ca .ca
+AddLanguage cs .cs
+AddLanguage de .de
+AddLanguage es .es
+AddLanguage fr .fr
 AddLanguage hu .hu
-
+AddLanguage it .it
+AddLanguage ja .ja
+AddLanguage nl .nl
+AddLanguage zh .zh
 
 
 # FIXME: separate this from the main "root" .htaccess material