forked from creativecommons/creativecommons.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapache.conf
226 lines (183 loc) · 10.7 KB
/
apache.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
<Macro CCVHost ${host} ${proto} ${dir} ${logdir}>
ServerName ${host}
DocumentRoot ${dir}/docroot
ErrorLog ${logdir}/error.log
CustomLog ${logdir}/access.log combined
#----------
# Main (general configs)
#----------
# Display PHP errors to users of the staging site.
php_value display_errors 1
FileETag INode MTime Size
Options +ExecCGI
SuexecUserGroup webadmin webadmin
<Location /licenses>
DirectoryIndex deed
DefaultType text/html
AddDefaultCharset utf-8
</Location>
<Location /ccengine-fcgi>
DefaultType text/html
AddDefaultCharset utf-8
</Location>
<Location /cc.engine-cache>
DefaultType text/html
AddDefaultCharset utf-8
</Location>
# Always serve up deeds as text/html, even when the country code
# extension makes Apache think it's something else, like .pl being
# a perl script instead of Poland, but not if it's a CSS file.
<LocationMatch "^/licenses/.*/deed(?!3.css).*$">
ForceType text/html
</LocationMatch>
<LocationMatch "^/cc.engine-cache/.*/deed.*">
ForceType text/html
</LocationMatch>
# We only want relative URLs to point to creativecommons.org and nothing else
# like www.CC.org, etc.
UseCanonicalName On
# Let's have Apache set some caching options for most images on CC.org
<Directory ${dir}/docroot/wp-content/uploads>
ExpiresActive On
ExpiresDefault A60480800
</Directory>
<Directory ${dir}/docroot/images>
ExpiresActive On
ExpiresDefault A60480800
</Directory>
DirectoryIndex index.php index.html
### ------------------------- ####
## BEGIN mod_rewrite section ##
### ------------------------- ####
RewriteEngine on
#----------
# Logging. Uncomment these lines and adjust the log level for debugging. Make
# sure to recomment them and restart Apache when done because the file will
# become immense in a hurry.
#----------
#RewriteLog /tmp/rewrite.log
#RewriteLogLevel 5
#----------
# Config
#----------
RewriteMap uppercase int:toupper
#----------
# License engine and legalcode
#----------
Alias /ccengine-fcgi ${dir}/python_env/bin/ccengine.fcgi
Alias /cc.engine-cache ${dir}/python_env/cache
# Redirect all /license to /choose before we go any deeper
RewriteRule ^/choose$ ${proto}://${host}/choose/ [L,R=301]
RewriteRule ^/license$ ${proto}://${host}/choose/ [L,R=301]
# Fixes this repercussions of this bug:
# http://code.creativecommons.org/issues/issue898
RewriteRule ^/licenses/CC0/1.0(.*)$ /publicdomain/zero/1.0$1 [L,R=301]
# Legalcode rewrites
# FIXME: eval whether we should use the LHS as the actual file structure so we don't need the rewrites
RewriteRule ^/legalcode ${proto}://${host}/ [L,R=301]
RewriteRule .*legalcode/$ ${proto}://${host}/ [L,R=301]
RewriteRule ^/licenses/(.*)sampling\+/1.0/(.*)/legalcode$ /legalcode/$1samplingplus_1.0_$2.html [L]
RewriteRule ^/licenses/(.*)sampling\+/1.0/legalcode$ /legalcode/$1samplingplus_1.0.html [L]
RewriteRule ^/licenses/(.*)/([0-9]\.[0-9])/(.*)/legalcode\.([A-Za-z-]+)$ /legalcode/$1_$2_$3_$4.html [L]
RewriteRule ^/licenses/(.*)/([0-9]\.[0-9])/legalcode\.([a-z][a-z])$ /legalcode/$1_$2_$3.html [L]
RewriteRule ^/licenses/(.*)/([0-9]\.[0-9])/(.*)/legalcode$ /legalcode/$1_$2_$3.html [L]
RewriteRule ^/licenses/(.*)/([0-9]\.[0-9])/legalcode$ /legalcode/$1_$2.html [L]
RewriteRule ^/licenses/(.*)/([0-9]\.[0-9])/legalcode\.txt$ /legalcode/$1_$2.txt [L]
RewriteRule ^/publicdomain/(.*)/([0-9]\.[0-9])/legalcode$ /legalcode/$1_$2.html [L]
RewriteRule ^/publicdomain/(.*)/([0-9]\.[0-9])/legalcode\.([a-z][a-z])$ /legalcode/$1_$2_$3.html [L]
RewriteRule ^/publicdomain/(.*)/([0-9]\.[0-9])/legalcode\.txt$ /legalcode/$1_$2.txt [L]
# License RDF rewrites
# FIXME: eval whether we should use the LHS as the actual file structure so we don't need the rewrites
RewriteRule ^/licenses/(.*)/([0-9]\.[0-9])/([a-z]+)/license_rdf$ /license_rdf/creativecommons.org_licenses_$1_$2_$3_.rdf [L,T=application/rdf+xml]
RewriteRule ^/licenses/(.*)/([0-9]\.[0-9])/([a-z]+)/rdf$ /license_rdf/creativecommons.org_licenses_$1_$2_$3_.rdf [L,T=application/rdf+xml]
RewriteRule ^/licenses/index.rdf$ /rdf/index.rdf [L,T=application/rdf+xml]
RewriteRule ^/licenses/publicdomain/license_rdf$ /license_rdf/creativecommons.org_licenses_publicdomain_.rdf [L,T=application/rdf+xml]
RewriteRule ^/licenses/publicdomain/rdf$ /license_rdf/creativecommons.org_licenses_publicdomain_.rdf [L,T=application/rdf+xml]
RewriteRule ^/(publicdomain|licenses)/(.*)/([0-9]\.[0-9])/license_rdf$ /license_rdf/creativecommons.org_$1_$2_$3_.rdf [L,T=application/rdf+xml]
RewriteRule ^/(publicdomain|licenses)/(.*)/([0-9]\.[0-9])/rdf$ /license_rdf/creativecommons.org_$1_$2_$3_.rdf [L,T=application/rdf+xml]
RewriteRule .*rdf/$ ${proto}://${host}/ [L,R=301]
# See if deed is cached before sending to cc.engine
# FIXME: eval memcache as an alternative?
RewriteCond %{REQUEST_URI} ^/licenses
RewriteCond ${dir}/python_env/cache/%{REQUEST_FILENAME} -s
RewriteRule ^/licenses/(.*) /cc.engine-cache/licenses/$1 [L,PT]
# FIXME: do we really need rewrites for other licenses like GPL, etc?
RewriteRule (.*)licence(.*) ${proto}://${host}$1license$2 [L,R=301]
RewriteRule ^/(license|choose|characteristic|publicdomain)$ /$1/ [L,R=301]
RewriteRule ^/(license|choose|characteristic|publicdomain)/(.*) /ccengine-fcgi/$1/$2 [PT,L]
RewriteRule ^/licenses$ ${proto}://${host}/licenses/ [L,R=301]
RewriteRule ^/licenses/(.*)/([0-9]\.[0-9])/([a-z][a-z])$ ${proto}://${host}/licenses/$1/$2/$3/ [L,R=301]
RewriteRule ^/licenses/(.*)/([0-9]\.[0-9])/([Ss]cotland)$ ${proto}://${host}/licenses/$1/$2/scotland/ [L,R=301]
RewriteRule ^/licenses/(.*)([0-9])$ ${proto}://${host}/licenses/$1$2/ [L,R=301]
RewriteRule ^/licenses/(.*)/2.0/ar/(.*)$ ${proto}://${host}/licenses/$1/2.5/ar/$2 [L,R=301]
RewriteRule ^/licenses/BSD/legalcode http://opensource.org/licenses/bsd-license.php [L,R]
RewriteRule ^/licenses/by-nc-nd/2.0/deed-music$ ${proto}://${host}/licenses/by-nc-nd/2.0/ [L,R=301]
RewriteRule ^/licenses/(.*)/deed.(.*)/$ ${proto}://${host}/ [L,R=301]
RewriteRule ^/licenses/eldred-pd/$ http://web.archive.org/web/20030115160926/http://www.creativecommons.org/licenses/eldred-pd [L,R=301]
RewriteRule ^/licenses/GPL/2.0/rdf$ http://www.gnu.org/licenses/gpl-2.0.rdf [R=301,L]
RewriteRule ^/licenses/LGPL/2.1/rdf$ http://www.gnu.org/licenses/lgpl-2.1.rdf [R=301,L]
RewriteRule ^/licenses/meet-the-licenses$ ${proto}://${host}/licenses/ [L,R=301]
RewriteRule ^/licenses/MIT/legalcode http://opensource.org/licenses/mit-license.php [L,R]
RewriteRule ^/licenses/publicdomain/1.0(.*)$ ${proto}://${host}/licenses/publicdomain/ [L,R=301]
RewriteRule ^/licenses/zero/1.0/(.*) /publicdomain/zero/1.0/$1 [L,R=301]
RewriteRule ^/licesne(.*)$ ${proto}://${host}/choose$1 [L,R=301]
RewriteRule ^/public_domain ${proto}://${host}/publicdomain/ [R=301,L]
RewriteRule ^/licenses/(.*) /ccengine-fcgi/licenses/$1 [PT,L]
#----------
# Redirects to CC.net
#----------
# FIXME: a bunch of these have moved / don't exist anymore
RewriteRule ^/about/affiliates.*$ https://creativecommons.net/supporters [R=301,L]
RewriteRule ^/about/lessigletter.*$ https://creativecommons.net/letters [L,R=301]
RewriteRule ^/about/supporters$ https://creativecommons.net/supporters [L,R=301]
RewriteRule ^/donate$ https://creativecommons.net/donate [R=301,L]
RewriteRule /learn/aboutus/supporters$ https://creativecommons.net/supporters [R=301,L]
RewriteRule ^/store$ https://creativecommons.net/store [L,R=301]
RewriteRule /support/getabutton$ https://creativecommons.net/supportcc [R=301,L]
RewriteRule /support/summit$ https://creativecommons.net [R=301,L]
RewriteRule ^/support/?$ https://creativecommons.net/ [L,R=301]
#----------
# Miscellaneous
#----------
# Map backwardly named license types to their actual location
RewriteRule ^/licenses/by-nc-nd/1.0/(.*)$ ${proto}://${host}/licenses/by-nd-nc/1.0/$1 [L,R=301]
RewriteRule ^/licenses/by-nd-nc/2.0/(.*)$ ${proto}://${host}/licenses/by-nc-nd/2.0/$1 [L,R=301]
# Map the namespace document and schema URLs
# FIXME: are symlinks cleaner?
RewriteRule ^/ns$ /rdf/ns.html [L]
RewriteRule ^/schema.rdf$ /rdf/schema.rdf [L]
#----------
# WordPress rules here instead of .htaccess
#----------
# NOTE: sometimes Wordpress decides what page to display based on both the
# query string AND the REQUEST_URI. mod_rewrite does not alter the
# REQUEST_URI, and therefore mod_rewrite by itself is not always enough to
# coerce Wordpress into doing what we want. In these case, add the query
# argument '&roflcopter' to whatever RewriteRule. This will signal a special
# plugin (cc_rewrite_request_uri.php) to actually alter the REQUEST_URI in the
# PHP environment to be equivalent to the right side of the RewriteRule.
# Catch requests to certain posts and feed them to Wordpress in a way that
# it knows how to handle
RewriteRule ^/weblog(/archive|)/entry/(\d+)/?$ /index.php?p=$2&%{QUERY_STRING}&roflcopter [L]
RewriteRule ^/press-releases/entry/(\d+)/?$ /index.php?p=$1&roflcopter [L]
# Catch any requests for the general /weblog/archive and also to the
# archives for any particular year/month and then redirect the client
# to the new-style permalink
RewriteRule ^/weblog/archive(/?.*)$ http://${host}/weblog$1 [L,R=301]
# Catch any old permalinks that point to long, ugly post names. The
# CC Permalink Mapper will get this request and redirect the user accordingly.
# But don't do this if someone was trying to access some particular feed
RewriteCond %{REQUEST_URI} !^/([a-z-]+)/\d{4}/\d{2}/feed
RewriteRule ^/([a-z-]+)/\d{4}/\d{2}/([a-zA-Z0-9-]+)/?$ /index.php?post_name=$2&category=$1&roflcopter [L]
# '<some path>/rss' returns an RSS 0.92 feed, which we don't want, so make any
# requests for '<some path>/rss' return an RSS 2 feed.
RewriteRule ^/(.*?)rss/?$ /index.php/$1?feed=rss2 [L]
# Get missing upload files from the main site
# FIXME - staging only
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
RewriteRule ^/(wp-content/uploads/.*)$ http://creativecommons.org/$1 [L]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</Macro>