Advertisement
Kawiesh

htaccess notes

Nov 18th, 2021
1,408
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Set default directory file
  2. #Load index.html if not found find index.php etc.
  3. DirectoryIndex index.html index.php
  4.  
  5. #Error pages
  6. ErrorDocument 404 "Not found"
  7. ErrorDocument 404 /error.html
  8.  
  9. #Enable Directory Listing (default)
  10. Options +Indexes
  11.  
  12. #Disable Directory Listing (403 Forbidden)
  13. Options -Indexes
  14.  
  15. #Enable Directory Listing but hide files
  16. #Hide all files
  17. IndexIgnore *
  18. #Hide specific files
  19. IndexIgnore *.jpg *.txt
  20.  
  21. #Block access from IP
  22. #Allow all except some
  23. Order Allow, Deny
  24. allow all
  25. deny from 123.45.6.7
  26. deny from 12.34.5
  27.  
  28. #Deny all except some
  29. Order Deny, Allow
  30. deny all
  31. allow from 192.168.0.0/24
  32. allow from 10.0.0
  33.  
  34.  
  35. Flags:
  36. NC => no case / case insensitive
  37. F => Forbidden
  38.  
  39.  
  40. #Turn on rewrite engine before rewrite rules declared
  41. RewriteEngine On
  42.  
  43. #Redirecting pages=> oldurl newurl [flags]
  44. RewriteRule ^example.html$ domain/newexample.html [R=301]
  45.  
  46.  
  47. #Block visitors \w certain referers
  48. RewriteCond %{HTTP_REFERER} example\.com [NC]
  49. RewriteRule .* - [F]
  50.  
  51.  
  52.  
Advertisement
RAW Paste Data Copied
Advertisement