.htaccess 1.9 KB

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