.htaccess 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. Options -MultiViews
  2. #
  3. # REWRITE
  4. #
  5. # Used to: create nice urls, force https, and hav the site multilanguage.
  6. #
  7. <IfModule mod_rewrite.c>
  8. RewriteEngine On
  9. RewriteBase /
  10. # Force https
  11. RewriteCond %{HTTPS} !=on
  12. RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
  13. # Add final slash.
  14. RewriteRule ^([a-zA-Z]{2})$ $1/ [R=301]
  15. # For files, remove the last /
  16. RewriteCond %{REQUEST_URI} ^/([a-zA-Z]{2}/)?(.{3,})/$
  17. RewriteCond %{DOCUMENT_ROOT}/%2 !-d
  18. RewriteCond %{REQUEST_URI} /$
  19. RewriteRule ^(.{3,})/$ $1 [R=301]
  20. # For sections, add the last /
  21. RewriteCond %{REQUEST_URI} ^/([a-zA-Z]{2}/)?(.{3,})$
  22. RewriteCond %{DOCUMENT_ROOT}/%2 -d
  23. RewriteCond %{REQUEST_URI} !/$
  24. RewriteRule ^(.{3,})$ $1/ [R=301]
  25. # Hide the 'index.php'
  26. RewriteRule ^(.*)index\.php?$ $1 [L,R=301]
  27. # Remove page extensions
  28. RewriteCond %{THE_REQUEST} ^GET\ (.*)\.(php|html)([#?][^\ ]*)?\ HTTP
  29. RewriteRule ^(.*)\.(php|html)$ $1 [R=301]
  30. # Language as GET param.
  31. RewriteCond %{REQUEST_FILENAME} !-d
  32. RewriteCond %{REQUEST_FILENAME} !-f
  33. RewriteCond %{REQUEST_URI} ^/([a-zA-Z]{2})(/(.*))?$
  34. RewriteRule ^([a-zA-Z]{2})(/(.*))?$ $3?lang=$1 [L,QSA]
  35. # Add .php extension when needed. TODO: Actualy used?
  36. RewriteCond %{REQUEST_FILENAME} !-d
  37. RewriteCond %{REQUEST_FILENAME} !-f
  38. RewriteCond %{REQUEST_FILENAME}.php -f
  39. RewriteRule ^(.*)$ $1\.php [L]
  40. # Redirect permalinks.
  41. RewriteRule ^project/([A-Z\-a-z0-9]{3,}+)[\/]?$ /project/project.php?permalink=$1 [NC]
  42. RewriteRule ^blog/([A-Z\-a-z0-9]{3,}+)[\/]?$ /blog/post.php?permalink=$1 [NC]
  43. RewriteRule ^help[\/]?$ /help/index.php [NC]
  44. RewriteRule ^(perfil|profile|profila)[\/]?$ /profile/index.php [NC]
  45. # PHP to xml.
  46. RewriteRule ^sitemap.xml$ /sitemap.php [NC]
  47. RewriteRule ^imgmap.xml$ /sitemap-image.php [NC]
  48. RewriteRule ^rss.xml$ /rss.php
  49. </ifModule>
  50. #
  51. # EXPIRES
  52. #
  53. # Used to: control the cache times of the different files on the server.
  54. #
  55. <IfModule mod_expires.c>
  56. ExpiresActive on
  57. ExpiresDefault "access plus 2 days"
  58. ExpiresByType application/javascript "access plus 6 days"
  59. ExpiresByType image/x-ico "access plus 12 days"
  60. ExpiresByType image/jpg "access plus 12 days"
  61. ExpiresByType image/jpeg "access plus 12 days"
  62. ExpiresByType image/gif "access plus 12 days"
  63. ExpiresByType image/png "access plus 12 days"
  64. ExpiresByType video/mkv "access plus 12 days"
  65. ExpiresByType text/css "access plus 6 days"
  66. ExpiresByType text/plain "access plus 6 days"
  67. </IfModule>
  68. #
  69. # HEADERS
  70. #
  71. # Used to: control the cache times of the different files on the client.
  72. #
  73. <ifModule mod_headers.c>
  74. <filesMatch "\.(ico|jpe?g|png|gif|swf)$">
  75. Header set Cache-Control "max-age=864000, public, must-revalidate"
  76. </filesMatch>
  77. <filesMatch "\.(css)$">
  78. Header set Cache-Control "max-age=864000, public, must-revalidate"
  79. </filesMatch>
  80. <filesMatch "\.(js)$">
  81. Header set Cache-Control "max-age=864000, private, must-revalidate"
  82. </filesMatch>
  83. <filesMatch "\.(x?html?|php)$">
  84. Header set Cache-Control "max-age=86400, private, must-revalidate"
  85. </filesMatch>
  86. </ifModule>
  87. <ifModule mod_deflate.c>
  88. AddOutputFilterByType DEFLATE text/html text/xml text/css text/plain
  89. AddOutputFilterByType DEFLATE image/x-icon
  90. AddOutputFilterByType DEFLATE image/svg+xml application/xhtml+xml application/xml
  91. AddOutputFilterByType DEFLATE application/rdf+xml application/rss+xml application/atom+xml
  92. AddOutputFilterByType DEFLATE text/javascript application/javascript application/x-javascript application/json
  93. AddOutputFilterByType DEFLATE application/x-font-ttf application/x-font-otf
  94. AddOutputFilterByType DEFLATE font/truetype font/opentype
  95. </ifModule>
  96. #
  97. # ERROR
  98. #
  99. # Used to: redirect to nice error pages.
  100. #
  101. ErrorDocument 403 /error/403.php
  102. ErrorDocument 404 /error/404.php
  103. ErrorDocument 500 /error/500.php