htaccess.txt 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. RewriteEngine on
  2. # Redirect to domain without www.
  3. RewriteCond %{HTTPS} off
  4. RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
  5. RewriteRule .* http://%1%{REQUEST_URI} [R=301,L]
  6. # Same for HTTPS:
  7. RewriteCond %{HTTPS} on
  8. RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
  9. RewriteRule .* https://%1%{REQUEST_URI} [R=301,L]
  10. # Stop hotlinking.
  11. RewriteCond %{HTTP_REFERER} !^$
  12. RewriteCond %{HTTP_REFERER} ^https?://([^/]+)/ [NC]
  13. RewriteCond %1#%{HTTP_HOST} !^(.+)#\1$
  14. RewriteRule \.(jpg|jpeg|png|gif|swf|svg)$ - [NC,F,L]
  15. # Custom error pages.
  16. ErrorDocument 400 /ErrorPages/HTTP400.html
  17. ErrorDocument 401 /ErrorPages/HTTP401.html
  18. ErrorDocument 403 /ErrorPages/HTTP403.html
  19. ErrorDocument 404 /ErrorPages/HTTP404.html
  20. ErrorDocument 500 /ErrorPages/HTTP500.html
  21. ErrorDocument 501 /ErrorPages/HTTP501.html
  22. ErrorDocument 502 /ErrorPages/HTTP502.html
  23. ErrorDocument 503 /ErrorPages/HTTP503.html
  24. # Prevent viewing of htaccess file.
  25. <Files .htaccess>
  26. order allow,deny
  27. deny from all
  28. </Files>
  29. # Prevent directory listings
  30. Options All -Indexes
  31. # Display PHP errors
  32. php_flag display_errors 1