.htaccess.prod 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <IfModule mod_rewrite.c>
  2. Options +FollowSymLinks
  3. Options -MultiViews
  4. RewriteEngine On
  5. RewriteBase /
  6. # Redirect everything to HTTPS
  7. RewriteCond %{HTTPS} off
  8. RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  9. # Remove www
  10. RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
  11. RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,QSA,NC,L]
  12. # Remove trailing slashes
  13. RewriteCond %{REQUEST_FILENAME} !-d
  14. RewriteRule ^(.*)/+$ /$1 [NC,L,R=301,QSA]
  15. # Rewrite for public assets
  16. RewriteRule .+/css/(.+)$ css/$1 [NC,L,QSA]
  17. RewriteRule .+/images/(.+)$ images/$1 [NC,L,QSA]
  18. RewriteRule .+/javascript/(.+)$ javascript/$1 [NC,L,QSA]
  19. # community/[community name]/post/[post hash_id]/[post title]/comment/[comment hash_id]
  20. RewriteRule community/.+/post/(.+)/.+/comment/(.+)$ post/$1#comment-$2 [NC,NE,L,QSA,R=301]
  21. # Redirect old urls
  22. RewriteRule community/.+/post/(.+)/.+$ post/$1 [NC,L,QSA,R=301]
  23. RewriteRule community/.+/post/(.+)/*$ post/$1 [NC,L,QSA,R=301]
  24. # community/[community name]
  25. RewriteRule community/.+$ / [NC,L,QSA,R=301]
  26. # Redirect /new to index.php
  27. RewriteRule ^new$ index.php?new [NC,L,QSA]
  28. # For votes from post/...
  29. RewriteRule post/vote$ vote.php [NC,L,QSA]
  30. # Show a post's page
  31. RewriteRule post/(.+)$ post.php?hash_id=$1 [NC,L,QSA]
  32. # Show a user's public profile
  33. RewriteRule user/(.+)$ user.php?username=$1 [NC,L,QSA]
  34. # Show a user's activity (private only)
  35. RewriteRule user_activity/(.+)$ user_activity.php?$1 [NC,L,QSA]
  36. # RSS
  37. RewriteRule ^rss/(.+)$ rss.php?sort=$1 [NC,L,QSA]
  38. RewriteRule ^rss$ rss/hot [NC,L,R=301]
  39. # Rewrite to the corresponding .php page
  40. # Not a directory
  41. RewriteCond %{REQUEST_FILENAME} !-d
  42. # A HTML file exists
  43. RewriteCond %{REQUEST_FILENAME}\.php -f
  44. # Route URL to the right HTML page
  45. RewriteRule (.+) $1.php [NC,L,QSA]
  46. # If the requested filename exists, simply serve it.
  47. # We only want to let Apache serve files and not directories.
  48. RewriteCond %{REQUEST_FILENAME} -f
  49. RewriteRule .? - [L]
  50. </IfModule>