|
| 1 | +# vim: ft=apache ts=4 sw=4 sts=4 sr et: |
1 | 2 | <VirtualHost *:80>
|
2 |
| - #UseCanonicalName Off |
3 |
| - |
4 | 3 | ServerName MAGICALPONY.legal.creativecommons.org
|
5 | 4 |
|
6 | 5 | VirtualDocumentRoot /srv/clones/MAGICALPONY/docroot
|
7 | 6 | DocumentRoot /srv/clones/MAGICALPONY/docroot
|
8 | 7 |
|
9 | 8 | RewriteEngine on
|
10 |
| - |
| 9 | + |
11 | 10 | #----------
|
12 | 11 | # Logging. Uncomment these lines and adjust the log level for debugging. Make
|
13 | 12 | # sure to recomment them and restart Apache when done because the file will
|
14 | 13 | # become immense in a hurry.
|
15 | 14 | #----------
|
16 |
| - |
| 15 | + |
17 | 16 | #RewriteLog /tmp/rewrite.log
|
18 | 17 | #RewriteLogLevel 5
|
19 |
| - |
| 18 | + |
20 | 19 | #----------
|
21 | 20 | # Config
|
22 | 21 | #----------
|
23 |
| - |
| 22 | + |
24 | 23 | RewriteMap uppercase int:toupper
|
25 |
| - |
| 24 | + |
26 | 25 | #----------
|
27 | 26 | # License engine and legalcode
|
28 | 27 | #----------
|
29 |
| - |
| 28 | + |
30 | 29 | Alias /ccengine-fcgi /srv/creativecommons.org/python_env/bin/ccengine.fcgi
|
31 | 30 | Alias /cc.engine-cache /srv/creativecommons.org/python_env/cache
|
32 |
| - |
| 31 | + |
33 | 32 | # Redirect all /license to /choose before we go any deeper
|
34 | 33 | RewriteRule ^/choose$ %{SERVER_PROTOCOL}://%{HTTP_HOST}/choose/ [L,R=301]
|
35 | 34 | RewriteRule ^/license$ %{SERVER_PROTOCOL}://%{HTTP_HOST}/choose/ [L,R=301]
|
36 |
| - |
| 35 | + |
37 | 36 | # Fixes this repercussions of this bug:
|
38 | 37 | # http://code.creativecommons.org/issues/issue898
|
39 | 38 | RewriteRule ^/licenses/CC0/1.0(.*)$ /publicdomain/zero/1.0$1 [L,R=301]
|
40 |
| - |
| 39 | + |
41 | 40 | # Legalcode rewrites
|
42 |
| - # FIXME: eval whether we should use the LHS as the actual file structure so we don't need the rewrites |
| 41 | + # FIXME: eval whether we should use the LHS as the actual file structure so we don't need the rewrites |
43 | 42 | RewriteRule ^/legalcode %{SERVER_PROTOCOL}://%{HTTP_HOST}/ [L,R=301]
|
44 | 43 | RewriteRule .*legalcode/$ %{SERVER_PROTOCOL}://%{HTTP_HOST}/ [L,R=301]
|
45 |
| - RewriteRule ^/licenses/(.*)sampling\+/1.0/(.*)/legalcode$ /legalcode/$1samplingplus_1.0_$2.html [L] |
46 |
| - RewriteRule ^/licenses/(.*)sampling\+/1.0/legalcode$ /legalcode/$1samplingplus_1.0.html [L] |
| 44 | + RewriteRule ^/licenses/(.*)sampling\+/1.0/(.*)/legalcode$ /legalcode/$1samplingplus_1.0_$2.html [L] |
| 45 | + RewriteRule ^/licenses/(.*)sampling\+/1.0/legalcode$ /legalcode/$1samplingplus_1.0.html [L] |
47 | 46 | RewriteRule ^/licenses/(.*)/([0-9]\.[0-9])/(.*)/legalcode\.([A-Za-z-]+)$ /legalcode/$1_$2_$3_$4.html [L]
|
48 |
| - RewriteRule ^/licenses/(.*)/([0-9]\.[0-9])/legalcode\.([a-z][a-z])$ /legalcode/$1_$2_$3.html [L] |
49 |
| - RewriteRule ^/licenses/(.*)/([0-9]\.[0-9])/(.*)/legalcode$ /legalcode/$1_$2_$3.html [L] |
50 |
| - RewriteRule ^/licenses/(.*)/([0-9]\.[0-9])/legalcode$ /legalcode/$1_$2.html [L] |
51 |
| - RewriteRule ^/licenses/(.*)/([0-9]\.[0-9])/legalcode\.txt$ /legalcode/$1_$2.txt [L] |
52 |
| - RewriteRule ^/publicdomain/(.*)/([0-9]\.[0-9])/legalcode$ /legalcode/$1_$2.html [L] |
| 47 | + RewriteRule ^/licenses/(.*)/([0-9]\.[0-9])/legalcode\.([a-z][a-z])$ /legalcode/$1_$2_$3.html [L] |
| 48 | + RewriteRule ^/licenses/(.*)/([0-9]\.[0-9])/(.*)/legalcode$ /legalcode/$1_$2_$3.html [L] |
| 49 | + RewriteRule ^/licenses/(.*)/([0-9]\.[0-9])/legalcode$ /legalcode/$1_$2.html [L] |
| 50 | + RewriteRule ^/licenses/(.*)/([0-9]\.[0-9])/legalcode\.txt$ /legalcode/$1_$2.txt [L] |
| 51 | + RewriteRule ^/publicdomain/(.*)/([0-9]\.[0-9])/legalcode$ /legalcode/$1_$2.html [L] |
53 | 52 | # -Aaa is for Chinese
|
54 |
| - RewriteRule ^/publicdomain/(.*)/([0-9]\.[0-9])/legalcode\.([a-z][a-z](-[A-Z][a-z][a-z][a-z])?)$ /legalcode/$1_$2_$3.html [L] |
| 53 | + RewriteRule ^/publicdomain/(.*)/([0-9]\.[0-9])/legalcode\.([a-z][a-z](-[A-Z][a-z][a-z][a-z])?)$ /legalcode/$1_$2_$3.html [L] |
55 | 54 | RewriteRule ^/publicdomain/(.*)/([0-9]\.[0-9])/legalcode\.txt$ /legalcode/$1_$2.txt [L]
|
56 |
| - |
| 55 | + |
57 | 56 | # License RDF rewrites
|
58 |
| - # FIXME: eval whether we should use the LHS as the actual file structure so we don't need the rewrites |
| 57 | + # FIXME: eval whether we should use the LHS as the actual file structure so we don't need the rewrites |
59 | 58 | RewriteRule ^/licenses/(.*)/([0-9]\.[0-9])/([a-z]+)/license_rdf$ /license_rdf/creativecommons.org_licenses_$1_$2_$3_.rdf [L,T=application/rdf+xml]
|
60 | 59 | RewriteRule ^/licenses/(.*)/([0-9]\.[0-9])/([a-z]+)/rdf$ /license_rdf/creativecommons.org_licenses_$1_$2_$3_.rdf [L,T=application/rdf+xml]
|
61 | 60 | RewriteRule ^/licenses/index.rdf$ /rdf/index.rdf [L,T=application/rdf+xml]
|
|
64 | 63 | RewriteRule ^/(publicdomain|licenses)/(.*)/([0-9]\.[0-9])/license_rdf$ /license_rdf/creativecommons.org_$1_$2_$3_.rdf [L,T=application/rdf+xml]
|
65 | 64 | RewriteRule ^/(publicdomain|licenses)/(.*)/([0-9]\.[0-9])/rdf$ /license_rdf/creativecommons.org_$1_$2_$3_.rdf [L,T=application/rdf+xml]
|
66 | 65 | RewriteRule .*rdf/$ %{SERVER_PROTOCOL}://%{HTTP_HOST}/ [L,R=301]
|
67 |
| - |
| 66 | + |
68 | 67 | # See if deed is cached before sending to cc.engine
|
69 |
| - # FIXME: eval memcache as an alternative? |
| 68 | + # FIXME: eval memcache as an alternative? |
70 | 69 | RewriteCond %{REQUEST_URI} ^/licenses
|
71 | 70 | RewriteCond /srv/clones/MAGICALPONY/python_env/cache/%{REQUEST_FILENAME} -s
|
72 | 71 | RewriteRule ^/licenses/(.*) /cc.engine-cache/licenses/$1 [L,PT]
|
73 |
| - |
74 |
| - # FIXME: do we really need rewrites for other licenses like GPL, etc? |
| 72 | + |
| 73 | + # FIXME: do we really need rewrites for other licenses like GPL, etc? |
75 | 74 | RewriteRule (.*)licence(.*) %{SERVER_PROTOCOL}://%{HTTP_HOST}$1license$2 [L,R=301]
|
76 | 75 | RewriteRule ^/(license|choose|characteristic|publicdomain)$ /$1/ [L,R=301]
|
77 | 76 | RewriteRule ^/(license|choose|characteristic|publicdomain)/(.*) /ccengine-fcgi/$1/$2 [PT,L]
|
|
187 | 186 | RewriteRule ^/press-releases/entry/40938 /press-releases/entry/40935 [L,R=301]
|
188 | 187 | RewriteRule ^/weblog/entry/40938 /press-releases/entry/40935 [L,R=301]
|
189 | 188 |
|
| 189 | + RewriteRule ^/weblog/entry/([-a-z0-9]+) /index.php?p=$1 [L,R=301] |
| 190 | + |
190 | 191 | #----------
|
191 | 192 | # Farming out old/removed CC.org content to CC Wiki
|
192 | 193 | #----------
|
|
246 | 247 |
|
247 | 248 | RewriteRule ^/government https://creativecommons.org/publicpolicy [L,R=301]
|
248 | 249 |
|
249 |
| - #---------- |
| 250 | + #---------- |
250 | 251 | # Redirects to CC.net
|
251 |
| - #---------- |
252 |
| - # FIXME: a bunch of these have moved / don't exist anymore |
253 |
| - |
| 252 | + #---------- |
| 253 | + # FIXME: a bunch of these have moved / don't exist anymore |
| 254 | + |
254 | 255 | RewriteRule ^/about/affiliates.*$ https://creativecommons.net/supporters [R=301,L]
|
255 | 256 | RewriteRule ^/about/lessigletter.*$ https://creativecommons.net/letters [L,R=301]
|
256 | 257 | RewriteRule ^/about/supporters$ https://creativecommons.net/supporters [L,R=301]
|
|
264 | 265 | #----------
|
265 | 266 | # Miscellaneous
|
266 | 267 | #----------
|
267 |
| - |
| 268 | + |
268 | 269 | # Map backwardly named license types to their actual location
|
269 | 270 | RewriteRule ^/licenses/by-nc-nd/1.0/(.*)$ %{SERVER_PROTOCOL}://%{HTTP_HOST}/licenses/by-nd-nc/1.0/$1 [L,R=301]
|
270 | 271 | RewriteRule ^/licenses/by-nd-nc/2.0/(.*)$ %{SERVER_PROTOCOL}://%{HTTP_HOST}/licenses/by-nc-nd/2.0/$1 [L,R=301]
|
271 |
| - |
| 272 | + |
272 | 273 | # Map the namespace document and schema URLs
|
273 |
| - # FIXME: are symlinks cleaner? |
| 274 | + # FIXME: are symlinks cleaner? |
274 | 275 | RewriteRule ^/ns$ /rdf/ns.html [L]
|
275 | 276 | RewriteRule ^/schema.rdf$ /rdf/schema.rdf [L]
|
276 | 277 |
|
|
301 | 302 | #----------
|
302 | 303 | # WordPress rules here instead of .htaccess
|
303 | 304 | #----------
|
304 |
| - |
| 305 | + |
305 | 306 | # NOTE: sometimes Wordpress decides what page to display based on both the
|
306 | 307 | # query string AND the REQUEST_URI. mod_rewrite does not alter the
|
307 | 308 | # REQUEST_URI, and therefore mod_rewrite by itself is not always enough to
|
308 | 309 | # coerce Wordpress into doing what we want. In these case, add the query
|
309 | 310 | # argument '&roflcopter' to whatever RewriteRule. This will signal a special
|
310 | 311 | # plugin (cc_rewrite_request_uri.php) to actually alter the REQUEST_URI in the
|
311 | 312 | # PHP environment to be equivalent to the right side of the RewriteRule.
|
312 |
| - |
| 313 | + |
313 | 314 | # Catch requests to certain posts and feed them to Wordpress in a way that
|
314 | 315 | # it knows how to handle
|
315 | 316 | RewriteRule ^/weblog(/archive|)/entry/(\d+)/?$ /index.php?p=$2&%{QUERY_STRING}&roflcopter [L]
|
316 | 317 | RewriteRule ^/press-releases/entry/(\d+)/?$ /index.php?p=$1&roflcopter [L]
|
317 |
| - |
| 318 | + |
318 | 319 | # Catch any requests for the general /weblog/archive and also to the
|
319 | 320 | # archives for any particular year/month and then redirect the client
|
320 | 321 | # to the new-style permalink
|
321 | 322 | RewriteRule ^/weblog/archive(/?.*)$ %{SERVER_PROTOCOL}://%{HTTP_HOST}/weblog$1 [L,R=301]
|
322 |
| - |
| 323 | + |
323 | 324 | # Catch any old permalinks that point to long, ugly post names. The
|
324 | 325 | # CC Permalink Mapper will get this request and redirect the user accordingly.
|
325 | 326 | # But don't do this if someone was trying to access some particular feed
|
326 | 327 | RewriteCond %{REQUEST_URI} !^/([a-z-]+)/\d{4}/\d{2}/feed
|
327 | 328 | RewriteRule ^/([a-z-]+)/\d{4}/\d{2}/([a-zA-Z0-9-]+)/?$ /index.php?post_name=$2&category=$1&roflcopter [L]
|
328 |
| - |
| 329 | + |
329 | 330 | # '<some path>/rss' returns an RSS 0.92 feed, which we don't want, so make any
|
330 | 331 | # requests for '<some path>/rss' return an RSS 2 feed.
|
331 | 332 | RewriteRule ^/(.*?)rss/?$ /index.php/$1?feed=rss2 [L]
|
332 |
| - |
| 333 | + |
333 | 334 | # Get missing upload files from the main site
|
334 | 335 | # NOTE: disable in production - for staging sites only (so media URLs will work)
|
335 | 336 | RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
|
336 | 337 | RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
|
337 | 338 | RewriteRule ^/(wp-content/uploads/.*)$ %{SERVER_PROTOCOL}://creativecommons.org/$1 [L]
|
338 |
| - |
| 339 | + |
339 | 340 | RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
|
340 | 341 | RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
|
341 | 342 | RewriteRule . /index.php [L]
|
|
354 | 355 | Require all granted
|
355 | 356 | </Location>
|
356 | 357 |
|
357 |
| - RewriteEngine On |
358 |
| - #RewriteLog "/var/log/apache2/rewrite.log" |
359 |
| - #RewriteLogLevel 3 |
360 | 358 | LogLevel alert rewrite:trace3
|
361 | 359 |
|
362 | 360 | </VirtualHost>
|
0 commit comments