|
| 1 | +# .htaccess config for www.sagemath.org |
| 2 | +# if something doesn't work - options need to be enabled |
| 3 | +# enable modules mod_include (SSI) and mod_headers (rewriting cache expires) |
| 4 | + |
| 5 | +DefaultLanguage en-US |
| 6 | + |
| 7 | +AddDefaultCharset UTF-8 |
| 8 | + |
| 9 | +ServerSignature Off |
| 10 | + |
| 11 | +# important |
| 12 | +Options +FollowSymLinks |
| 13 | + |
| 14 | +#file types, spkg is special! |
| 15 | +AddType application/octet-stream .spkg |
| 16 | +AddType video/x-flv .flv |
| 17 | +AddType application/x-shockwave-flash .swf |
| 18 | +AddType image/x-icon .ico |
| 19 | +AddType application/metalink+xml .metalink |
| 20 | +AddType text/plain .bib |
| 21 | +AddType application/vnd.openxmlformats-officedocument.wordprocessingml.document .docx |
| 22 | + |
| 23 | +# the custom 404, all others are defalt |
| 24 | +ErrorDocument 404 /404error.html |
| 25 | + |
| 26 | +# deflate compression except for the given ones |
| 27 | +SetOutputFilter DEFLATE |
| 28 | +SetEnvIfNoCase Request_URI \ |
| 29 | + \.(?:gif|jpe?g|png|avi|metalink|torrent|mpeg|flv|spkg|msi)$ no-gzip dont-vary |
| 30 | +SetEnvIfNoCase Request_URI \ |
| 31 | + \.(?:exe|spkg|deb|rpm|msi|iso|img|bzip|bzip2|t?gz|zip|gz2|sit|rar)$ no-gzip dont-vary |
| 32 | + |
| 33 | +# SSI part |
| 34 | +#NoExec disables the exec={} command in SSI, just security |
| 35 | +Options +IncludesNOExec |
| 36 | +XBitHack on |
| 37 | +BrowserMatchNoCase MSIE IE |
| 38 | +#Operating Systems |
| 39 | +BrowserMatchNoCase LINUX LINUX |
| 40 | +BrowserMatchNoCase MAC MAC |
| 41 | +BrowserMatchNoCase WINDOWS WIN |
| 42 | +AddHandler server-parsed .txt |
| 43 | + |
| 44 | +# this does some magic |
| 45 | +RewriteEngine On |
| 46 | +#search shortcut |
| 47 | +RewriteRule ^search search.html |
| 48 | +#RewriteRule ^download download.html |
| 49 | +RewriteRule ^/days2/sage-car.png old/days2/sage-car.png |
| 50 | + |
| 51 | +# .com -> .org |
| 52 | +RewriteCond %{HTTP_HOST} ^sagemath.com$ [NC] |
| 53 | +RewriteRule ^(.*)$ http://www.sagemath.org/$1 [R=301,L] |
| 54 | +# once again |
| 55 | +RewriteCond %{HTTP_HOST} ^www.sagemath.com$ [NC] |
| 56 | +RewriteRule ^(.*)$ http://www.sagemath.org/$1 [R=301,L] |
| 57 | + |
| 58 | +# reporting an issue |
| 59 | +Redirect 301 /report-issue http://ask.sagemath.org |
| 60 | +#old pages are moved - this catches wrong links |
| 61 | +Redirect 301 /old http://boxen.math.washington.edu/home/sagemath/www/ |
| 62 | +Redirect 301 /ack.html http://www.sagemath.org/development-ack.html |
| 63 | +Redirect 301 /dev.html http://www.sagemath.org/development.html |
| 64 | +Redirect 301 /art/ http://www.sagemath.org/old/art/ |
| 65 | +Redirect 301 /documentation.html http://www.sagemath.org/help.html |
| 66 | +Redirect 301 /lists.html http://www.sagemath.org/help-groups.html |
| 67 | +Redirect 301 /packages.html http://www.sagemath.org/download-packages.html |
| 68 | +Redirect 301 /dist/src/index.html http://www.sagemath.org/src/index.html |
| 69 | +Redirect 301 /pub.html http://www.sagemath.org/library-publications.html |
| 70 | +Redirect 301 /sage.html http://www.sagemath.org/ |
| 71 | +Redirect 301 /marketing.html http://www.sagemath.org/library-marketing.html |
| 72 | +Redirect 301 /library/books.html http://www.sagemath.org/library-books.html |
| 73 | +Redirect 301 /library/publications.html http://www.sagemath.org/library-publications.html |
| 74 | +Redirect 301 /library/stories.html http://www.sagemath.org/library-stories.html |
| 75 | +Redirect 301 /library/talks http://www.sagemath.org/talks |
| 76 | +Redirect 301 /library/why.html http://www.sagemath.org/library-why.html |
| 77 | +Redirect 301 /library/index.html http://www.sagemath.org/library.html |
| 78 | +Redirect 301 /library/index.html http://www.sagemath.org/library.html |
| 79 | +Redirect 301 /library/ http://www.sagemath.org/library.html |
| 80 | +Redirect 301 /src http://www.sagemath.org/download-source.html |
| 81 | +Redirect 301 /bin http://www.sagemath.org/download.html |
| 82 | +Redirect 301 /en/ http://www.sagemath.org/ |
| 83 | +Redirect 301 /src-old http://boxen.math.washington.edu/home/sagemath/www-files/src-old/ |
| 84 | +Redirect 301 /src-old/ http://boxen.math.washington.edu/home/sagemath/www-files/src-old/ |
| 85 | + |
| 86 | +# old wrong doc directory rewrite |
| 87 | +RewriteCond %{HTTP_HOST} ^www.sagemath.org$ [NC] |
| 88 | +RewriteRule ^doc/html(.*)$ http://www.sagemath.org/doc$1 [R=301,L] |
| 89 | +RewriteCond %{HTTP_HOST} ^sagemath.org$ [NC] |
| 90 | +RewriteRule ^doc/html(.*)$ http://www.sagemath.org/doc$1 [R=301,L] |
| 91 | + |
| 92 | +# old documentation pages |
| 93 | +#RewriteCond %{HTTP_HOST} ^www.sagemath.org$ [NC] |
| 94 | +#RewriteRule ^doc/ref(.*)$ http://www.sagemath.org/doc/reference$1 [R=301,L] |
| 95 | +#RewriteCond %{HTTP_HOST} ^sagemath.org$ [NC] |
| 96 | +#RewriteRule ^doc/ref(.*)$ http://www.sagemath.org/doc/reference$1 [R=301,L] |
| 97 | + |
| 98 | + |
| 99 | +# this translates the www. less hg request to the correct one |
| 100 | +RewriteCond %{HTTP_HOST} ^sagemath.org$ [NC] |
| 101 | +RewriteCond %{REQUEST_URI} ^/hg/(.*)$ [NC] |
| 102 | +RewriteRule ^(.*)$ http://www.sagemath.org/hg/%1 [R=301,L] |
| 103 | + |
| 104 | +# this translates sagemath.org/hg to /hg/ (file vs. directory) |
| 105 | +RewriteCond %{REQUEST_URI} ^/hg [NC] |
| 106 | +RewriteRule ^(.*)$ http://www.sagemath.org/hg/ [R=301,L] |
| 107 | + |
| 108 | +#CACHING - keep content files in browser cache for 3 hours, images 2 days, and packages never |
| 109 | +<IfModule mod_headers.c> |
| 110 | + <FilesMatch "\.(ico|gif|jpg|jpeg|png)$"> |
| 111 | + Header set Cache-Control "max-age=200000, public" |
| 112 | + </FilesMatch> |
| 113 | + <FilesMatch "\.(shtml|html|htm|txt|flv|avi|mpeg|js|css|pdf|swf|xml)$"> |
| 114 | + Header set Cache-Control "max-age=10000, public" |
| 115 | + </FilesMatch> |
| 116 | + <FilesMatch "\.(spkg|exe|tar|tar.gz|gz|tgz)$"> |
| 117 | + Header set Cache-Control "max-age=0" |
| 118 | + </FilesMatch> |
| 119 | +</IfModule> |
| 120 | + |
| 121 | +# I don't understand mod_expires ... |
| 122 | +#<IfModule mod_expires.c> |
| 123 | +# <FilesMatch "\.(flv|avi|mpeg|gif|jpg|jpeg|png|js|css|pdf|swf|xml|html|htm|txt)$"> |
| 124 | +# ExpiresDefault A10000 |
| 125 | +# </FilesMatch> |
| 126 | +#</IfModule> |
| 127 | + |
| 128 | + |
0 commit comments