1 # htaccess for root dir of lilypond.org
2 # ----------------------------------------------------
3 # The file comes from git master:
4 # Documentation/web/server/lilypond.org.htaccess
6 # Please do not edit it directly (unless something
7 # is critically broken); instead, change it in git
14 # Contributor 5.2 Uploading and security
15 # ----------------------------------------------------
19 # Permanent redirect from www.lilypond.org to lilypond.org
20 RewriteCond "%{HTTP_HOST}" "^www\.(.+)$" [NC]
21 RewriteRule "^/?(.*)$" "http://%1/$1" [R=301,L,NE]
23 # Deny following of symlinks by robots.
24 # HTTrack is a known offender.
25 # better yet, to redirect this to page that tells adminstrator
27 RewriteCond %{HTTP_USER_AGENT} httrack [NC]
28 RewriteRule ^.*/source/.*$ /please-respect-robots.txt.html [L]
31 RewriteCond %{HTTP_USER_AGENT} ^(.*)AhrefsBot(.*) [NC]
32 RewriteRule .* - [F,L]
34 # Permanent top level entry points -- ./doc
35 RedirectMatch ^/music-glossary /glossary
36 RedirectMatch ^/tutorial /learning
37 RedirectMatch ^/documentation/$ /doc
38 # Possibly resurrect this with new web site
39 # This breaks the documentation index with old site
40 # RedirectMatch ^/documentation$ /doc
42 RedirectMatch ^/bugs /bug-reports
43 #RedirectMatch ^/bugs http://code.google.com/p/lilypond/issues/list
44 # the new website already has an /authors
45 #RedirectMatch ^/authors /doc/Documentation/topdocs/AUTHORS
46 RedirectMatch ^/stable /doc/stable
47 # the new website has a dedicated page for development.
48 #RedirectMatch ^/development /doc/development
50 # Main doc URL redirects
51 RedirectMatch ^/doc/?$ /manuals
52 RedirectMatch ^/doc/stable/?$ /manuals
53 RedirectMatch ^/doc/development/?$ /development
55 # Allow to use deep links to latest stable or development docs
56 RedirectMatch ^/doc//*latest/*(.*)$ /doc/v2.19/$1
57 RedirectMatch ^/doc//*development/*(.*)$ /doc/v2.19/$1
58 RedirectMatch ^/doc//*stable/*(.*)$ /doc/v2.18/$1
59 RedirectMatch ^/doc//*([^v].*)$ /doc/v2.18/$1
60 RedirectMatch ^(/Documentation.*)$ /doc/v2.18$1
61 RedirectMatch ^/index$ /
63 # fix root calculation: no double slashes
64 # RedirectMatch ^(.*/)/+(.*)$ $1$2
66 ###########################################
68 ## Rewrite all non-existing files at toplevel to the /website/ dir, so our
69 ## internal structure for rsync doesn't have to be changed.
70 ## This works for the current/old site as well as the new one.
75 SetEnvIf REQUEST_URI .* WEB=/website
77 # Rewrite empty to /website
78 RewriteCond %{REQUEST_URI} ^/*$
79 RewriteRule ^(/*)$ %{ENV:WEB}/ [QSA,L]
81 # css Request without directory part
82 RewriteCond %{REQUEST_URI} ^/?[^/]+[.]css$
83 # ...that does not match match an existing file
84 RewriteCond %{REQUEST_FILENAME} !-f
85 # ...and does not match an existing directory
86 RewriteCond %{REQUEST_FILENAME} !-d
87 # ...prefix with website
88 RewriteRule ^(.+)$ %{ENV:WEB}/$1 [QSA,L]
90 # Request without trailing slash
91 RewriteCond %{REQUEST_URI} !.*/$
92 # ...that would access a directory in /website
93 RewriteCond %{DOCUMENT_ROOT}%{ENV:WEB}%{REQUEST_URI} -d
94 # ...and does not start with /web
95 RewriteCond %{REQUEST_URI} !^%{ENV:WEB}
96 RewriteCond %{REQUEST_URI} !^/website
97 # ...and does not start with /doc$
98 RewriteCond %{REQUEST_URI} !^/doc$
99 # ...add trailing slash for [menu] and to avoid /web/ in browser url
100 RewriteRule ^(.+)$ http://%{HTTP_HOST}/$1/ [R,QSA,L]
102 # Request that does not start with /website
103 RewriteCond %{REQUEST_URI} !^/website
104 RewriteCond %{REQUEST_URI} !^%{ENV:WEB}
105 # ...and does not start with /doc/
106 RewriteCond %{REQUEST_URI} !^/doc/
107 # ...and is not /doc$
108 RewriteCond %{REQUEST_URI} !^/doc$
109 # ...and does not match match an existing file
110 RewriteCond %{REQUEST_FILENAME} !-f
111 # ...and does not match an existing directory
112 RewriteCond %{REQUEST_FILENAME} !-d
114 RewriteRule ^(.+)$ %{ENV:WEB}/$1 [QSA,L]
116 ## Redirect the old web/ to the homepage
117 RedirectMatch 301 ^/web/.* /
119 ###########################################
121 # latin1 version copied to web and doc/2.x
122 AddDefaultCharset utf-8
123 AddCharset utf-8 .html
129 AddCharset utf-8 .txt
131 # Add extensions for language negotiation
132 # See: https://www.w3.org/International/questions/qa-apache-lang-neg
145 # FIXME: separate this from the main "root" .htaccess material