#RewriteMap lc int:tolower
ErrorDocument 403 /error/403.php
ErrorDocument 404 /error/404.php
ErrorDocument 500 /error/500.php
#AddHandler application/x-httpd-php .xml
#AddType application/x-httpd-php .xml
AddType application/x-httpd-php .xml
AddHandler php5-cgi .xml
#
# Order allow, deny
# Deny from all
#
Options +FollowSymlinks
RewriteEngine on
CheckSpelling on
RewriteRule ^sitemap.xml$ /sitemap.php [NC]
RewriteRule ^imgmap.xml$ /sitemap-image.php [NC]
RewriteRule ^rss.xml$ /rss.php [NC]
RewriteRule ^blog/buscar/([A-Za-z0-9]+)/([A-Za-z0-9]+)[\/]?$ /blog/buscar.php?where=$1&query=$2 [NC]
RewriteRule ^blog/([A-Z\-a-z0-9]{3,}+)[\/]?$ /blog/post.php?perm=$1 [NC]
RewriteRule ^osm/([A-Z\-a-z0-9]+)[\/]?.xml$ /osm/index.php?route=$1 [NC]
RewriteRule ^gpx/([A-Z\-a-z0-9]+)[\/]?.gpx$ /gpx/index.php?route=$1 [NC]
RewriteRule ^lablanca/([0-9]+)[\/]?$ /lablanca/index.php?year=$1 [NC]
RewriteRule ^lablanca/programa[\/]?$ /lablanca/programa.php?gm=1 [NC]
RewriteRule ^lablanca/programa/([A-Za-z]+)[\/]?$ /lablanca/programa.php?gm=$1 [NC]
RewriteRule ^lablanca/programa/([A-Za-z]+)/([0-9]+)[\/]?$ /lablanca/programa.php?gm=$1&year=$2 [NC]
RewriteRule ^archivo/([A-Z\-a-z0-9]{3,}+)[\/]?$ /archivo/index.php?file=$1 [NC]
RewriteRule ^actividades/search/([A-Za-z0-9]+)/([A-Za-z0-9]+)[\/]?$ /actividades/buscar.php?where=$1&query=$2 [NC]
RewriteRule ^actividades/([A-Z\-a-z0-9{3,}]+)[\/]?$ /actividades/actividad.php?perm=$1 [NC]
RewriteRule ^ayuda[\/]?$ /ayuda/index.php [NC]
RewriteRule ^galeria/upload[\/]?$ /galeria/upload.php [NC]
RewriteRule ^galeria/([A-Z\-a-z0-9{3,}]+)[\/]?$ /galeria/album.php?perm=$1 [NC]
RewriteRule ^galeria/([A-Z\-a-z0-9{3,}]+)/([A-Z\-a-z0-9{3,}]+)[\/]?$ /galeria/photo.php?album=$2&perm=$1 [NC]
RewriteRule ^traducir/eu[\/]?$ /traducir/index.php?l=eu [NC]
RewriteRule ^traducir/en[\/]?$ /traducir/index.php?l=en [NC]
#API redirections
#TODO: This changes the url in the browser
#RewriteRule ^API/V([{0-9}]+)/help/([A-Z\-a-z0-9{3,}]+)$ /API/V$1/help/$2.php [NC,QSA,L]
#RewriteRule ^API/V([{0-9}]+)/help/([A-Z\-a-z0-9{3,}]+)/$ /API/V$1/help/$2.php [L,NC]
#Force https TODO
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
# BEGIN Cache-Control Headers
ExpiresActive on
# ExpiresDefault "access plus 1 month"
ExpiresByType application/javascript "access plus 6 days"
ExpiresByType image/x-ico "access plus 12 days"
ExpiresByType image/jpg "access plus 12 days"
ExpiresByType image/jpeg "access plus 12 days"
ExpiresByType image/gif "access plus 12 days"
ExpiresByType image/png "access plus 12 days"
ExpiresByType video/mkv "access plus 12 days"
ExpiresByType text/css "access plus 6 days"
ExpiresByType text/plain "access plus 6 days"
# BEGIN Cache-Control Headers
Header set Cache-Control "max-age=864000, public, must-revalidate"
Header set Cache-Control "max-age=864000, public, must-revalidate"
Header set Cache-Control "max-age=864000, private, must-revalidate"
Header set Cache-Control "max-age=86400, private, must-revalidate"
# END Cache-Control Headers
AddOutputFilterByType DEFLATE text/html text/xml text/css text/plain
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE image/svg+xml application/xhtml+xml application/xml
AddOutputFilterByType DEFLATE application/rdf+xml application/rss+xml application/atom+xml
AddOutputFilterByType DEFLATE text/javascript application/javascript application/x-javascript application/json
AddOutputFilterByType DEFLATE application/x-font-ttf application/x-font-otf
AddOutputFilterByType DEFLATE font/truetype font/opentype
# Enable memory caching
#CacheEnable mem /
# Limit the size of the cache to 1 Megabyte
#MCacheSize 1024
#CacheFile footer.php header.php img/*/*/*.jpg