Apr 7, 2023

HTaccess

htaccess is a very ancient configuration file that controls the Web Server running your website, and is one of the most powerful configuration files you will ever come across. .htaccess has the ability to control access/settings for the HyperText Transfer Protocol (HTTP) using Password Protection, 301 Redirects, rewrites, and much much more. This is because this configuration file was coded in the earliest days of the web (HTTP), for one of the first Web Servers ever! Eventually these Web Servers (configured with htaccess) became known as the World Wide Web, and eventually grew into the Internet we use today.

Table of Contents

  1. Introduction
    1. Htaccess - Evolved
    2. AskApache Htaccess Journey
    3. What Is .htaccess
      1. Creating Htaccess Files
      2. Htaccess Scope
    4. Htaccess File Syntax
    5. Htaccess Directives
    6. Main Server Config Examples
    7. Example .htaccess Code Snippets
      1. Redirect Everyone Except IP address to alternate page
      2. When developing sites
      3. Fix double-login prompt
      4. Set Timezone of the Server (GMT)
      5. Administrator Email for ErrorDocument
      6. ServerSignature for ErrorDocument
      7. Charset and Language headers
      8. Disallow Script Execution
      9. Deny Request Methods
      10. Force "File Save As" Prompt
      11. Show CGI Source Code
      12. Serve all .pdf files on your site using .htaccess and mod_rewrite with the php script.
      13. Rewrite to www
      14. Rewrite to www dynamically
      15. 301 Redirect Old File
      16. 301 Redirect Entire Directory
      17. Protecting your php.cgi
      18. Set Cookie based on Request
      19. Set Cookie with env variable
      20. Custom ErrorDocuments
      21. Implementing a Caching Scheme with .htaccess
      22. Password Protect single file
      23. Password Protect multiple files
      24. Send Custom Headers
      25. Blocking based on User-Agent Header
      26. Blocking with RewriteCond
      27. .htaccess for mod_php
      28. .htaccess for php as cgi
      29. Shell wrapper for custom php.ini
      30. Add values from HTTP Headers
      31. Stop hotlinking
    8. Example .htaccess Files
    9. Advanced Mod_Rewrites
      1. Directory Protection
      2. Password Protect wp-login.php
      3. Password Protect wp-admin
      4. Protect wp-content
      5. Protect wp-includes
      6. Common Exploits
      7. Stop Hotlinking
      8. Safe Request Methods
      9. Forbid Proxies
      10. Real wp-comments-post.php
      11. HTTP PROTOCOL
      12. SPECIFY CHARACTERS
      13. BAD Content Length
      14. BAD Content Type
      15. Missing HTTP_HOST
      16. Bogus Graphics Exploit
      17. No UserAgent, Not POST
      18. No Referer, No Comment
      19. Trackback Spam
      20. Map all URIs except those corresponding to existing files to a handler
      21. Map any request to a handler
      22. And for CGI scripts:
      23. Map URIs corresponding to existing files to a handler instead
      24. Deny access if var=val contains the string foo.
      25. Removing the Query String
      26. Adding to the Query String
      27. Rewriting For Certain Query Strings
      28. Modifying the Query String
    10. Best .htaccess Articles
      1. .htaccess for Webmasters
      2. Mod_Rewrite URL Rewriting
      3. 301 Redirects without mod_rewrite
      4. Secure PHP with .htaccess
      5. .htaccess Cookie Manipulation
      6. .htaccess Caching
      7. Password Protection and Authentication
      8. Control HTTP Headers
      9. Blocking Spam and bad Bots
      10. PHP htaccess tips
      11. HTTP to HTTPS Redirects with mod_rewrite
      12. SSL in .htaccess
      13. SetEnvIf and SetEnvIfNoCase in .htaccess
      14. Site Security with .htaccess
      15. Merging Notes
    11. My Favorite .htaccess Links
    12. Htaccess Directives
    13. Htaccess Variables
    14. Htaccess Modules
    15. Htaccess Software
    16. Technical Look at .htaccess
      1. Per-directory configuration structures
      2. Command handling
        1. mod_autoindex
        2. mod_rewrite
      3. Side notes --- per-server configuration, virtual servers, etc.
      4. Litespeed Htaccess support

For Help see HTaccess.guru

No comments: