]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/web/server/lilypond.org.htaccess
d6bc37fb5936ebfd6ffefd80f5b8027664e26d09
[lilypond.git] / Documentation / web / server / lilypond.org.htaccess
1 # htaccess for root dir of lilypond.org
2 # ----------------------------------------------------
3 #   The file comes from git master:
4 #   Documentation/web/server/lilypond.org.htaccess
5 #
6 #   Please do not edit it directly (unless something
7 #   is critically broken); instead, change it in git
8 #   and then do the:
9 #     update-git.sh
10 #     check-git.sh
11 #     copy-git.sh
12 #     make-website.sh
13 #  as discussed in:
14 #    Contributor 5.2 Uploading and security
15 # ----------------------------------------------------
16
17 RewriteEngine On
18
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]
22
23 # Deny following of symlinks by robots.
24 # HTTrack is a known offender.
25 # better yet, to redirect this to page that tells adminstrator
26 # about brokenness
27 RewriteCond %{HTTP_USER_AGENT} httrack [NC]
28 RewriteRule ^.*/source/.*$ /please-respect-robots.txt.html [L]
29
30 # Deny rogue crawler
31 RewriteCond %{HTTP_USER_AGENT} ^(.*)AhrefsBot(.*) [NC]
32 RewriteRule .* - [F,L]
33
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
41 #
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 # the new website has news on the main page
47 RedirectMatch ^/news    /
48 RedirectMatch ^/stable    /doc/stable
49 # the new website has a dedicated page for development.
50 #RedirectMatch ^/development    /doc/development
51
52 # Main doc URL redirects
53 RedirectMatch ^/doc/?$ /manuals
54 RedirectMatch ^/doc/stable/?$ /manuals
55 RedirectMatch ^/doc/development/?$ /development
56
57 # Allow to use deep links to latest stable or development docs
58 RedirectMatch ^/doc//*latest/*(.*)$ /doc/v2.19/$1
59 RedirectMatch ^/doc//*development/*(.*)$ /doc/v2.19/$1
60 RedirectMatch ^/doc//*stable/*(.*)$ /doc/v2.18/$1
61 RedirectMatch ^/doc//*([^v].*)$ /doc/v2.18/$1
62 RedirectMatch ^(/Documentation.*)$ /doc/v2.18$1
63 RedirectMatch ^/index$ /
64
65 # fix root calculation: no double slashes
66 # RedirectMatch ^(.*/)/+(.*)$ $1$2
67
68 ###########################################
69
70 ## Rewrite all non-existing files at toplevel to the /website/ dir, so our
71 ## internal structure for rsync doesn't have to be changed.
72 ## This works for the current/old site as well as the new one.
73
74 RewriteEngine on
75 RewriteBase /
76
77 SetEnvIf REQUEST_URI .* WEB=/website
78
79 # Rewrite empty to /website
80 RewriteCond %{REQUEST_URI} ^/*$
81 RewriteRule ^(/*)$ %{ENV:WEB}/ [QSA,L]
82
83 # css Request without directory part
84 RewriteCond %{REQUEST_URI} ^/?[^/]+[.]css$
85 # ...that does not match match an existing file
86 RewriteCond %{REQUEST_FILENAME} !-f
87 # ...and does not match an existing directory
88 RewriteCond %{REQUEST_FILENAME} !-d
89 # ...prefix with website
90 RewriteRule ^(.+)$ %{ENV:WEB}/$1 [QSA,L]
91
92 # Request without trailing slash
93 RewriteCond %{REQUEST_URI} !.*/$
94 # ...that would access a directory in /website
95 RewriteCond %{DOCUMENT_ROOT}%{ENV:WEB}%{REQUEST_URI} -d
96 # ...and does not start with /web
97 RewriteCond %{REQUEST_URI} !^%{ENV:WEB}
98 RewriteCond %{REQUEST_URI} !^/website
99 # ...and does not start with /doc$
100 RewriteCond %{REQUEST_URI} !^/doc$
101 # ...add trailing slash for [menu] and to avoid /web/ in browser url
102 RewriteRule ^(.+)$ http://%{HTTP_HOST}/$1/ [R,QSA,L]
103
104 # Request that does not start with /website
105 RewriteCond %{REQUEST_URI} !^/website
106 RewriteCond %{REQUEST_URI} !^%{ENV:WEB}
107 # ...and does not start with /doc/
108 RewriteCond %{REQUEST_URI} !^/doc/
109 # ...and is not /doc$
110 RewriteCond %{REQUEST_URI} !^/doc$
111 # ...and does not match match an existing file
112 RewriteCond %{REQUEST_FILENAME} !-f
113 # ...and does not match an existing directory
114 RewriteCond %{REQUEST_FILENAME} !-d
115 # ..prefix with /web
116 RewriteRule ^(.+)$ %{ENV:WEB}/$1 [QSA,L]
117
118 ## Redirect the old web/ to the homepage
119 RedirectMatch 301 ^/web/.* /
120
121 ###########################################
122
123 # latin1 version copied to web and doc/2.x
124 AddDefaultCharset utf-8
125 AddCharset utf-8 .html
126 AddCharset utf-8 .de
127 AddCharset utf-8 .en
128 AddCharset utf-8 .es
129 AddCharset utf-8 .fr
130 AddCharset utf-8 .nl
131 AddCharset utf-8 .txt
132
133 # Add extensions for language negotiation
134 # See: https://www.w3.org/International/questions/qa-apache-lang-neg
135 AddLanguage ca .ca
136 AddLanguage cs .cs
137 AddLanguage de .de
138 AddLanguage es .es
139 AddLanguage fr .fr
140 AddLanguage hu .hu
141 AddLanguage it .it
142 AddLanguage ja .ja
143 AddLanguage nl .nl
144 AddLanguage zh .zh
145
146
147 # FIXME: separate this from the main "root" .htaccess material
148 DirectoryIndex index
149