← 返回
开发者工具 中文

htaccess Generator

Generate .htaccess files for Apache web servers. Use when creating redirect rules, URL rewrites, security headers, HTTPS enforcement, IP blocking, caching ru...
生成 .htaccess 文件,用于 Apache 服务器的重定向、URL 重写、安全头、HTTPS 强制、IP 封锁、缓存等配置。
johnnywang2001
开发者工具 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 450
下载
💾 12
安装
1
版本
#apache#latest#security#server#web

概述

htaccess-gen

Generate production-ready .htaccess configurations from the command line.

Quick Start

# Generate HTTPS redirect + security headers + caching
python3 scripts/htaccess_gen.py generate --https --security-headers --caching

# Generate redirect rules
python3 scripts/htaccess_gen.py redirect --from /old-page --to /new-page --type 301

# Block IPs
python3 scripts/htaccess_gen.py generate --block-ip 192.168.1.100 --block-ip 10.0.0.0/24

# Full production config
python3 scripts/htaccess_gen.py generate --https --www --security-headers --caching --gzip --error-pages --hotlink-protection --output .htaccess

Commands

generate

Create a complete .htaccess file with selected features.

Options:

  • --https — Force HTTPS redirect
  • --www — Force www prefix (or --no-www to remove it)
  • --security-headers — Add security headers (X-Frame-Options, X-Content-Type-Options, Referrer-Policy, Permissions-Policy, HSTS)
  • --caching — Add browser caching rules (mod_expires)
  • --gzip — Enable gzip/deflate compression
  • --error-pages — Add custom error page directives (403, 404, 500)
  • --hotlink-protection — Prevent image hotlinking
  • --domain — Your domain name (used for hotlink protection and www rules)
  • --block-ip — Block an IP address or CIDR range (repeatable)
  • --cors — Enable CORS headers
  • --cors-origin — Specific allowed origin (default: *)
  • --index — Set directory index file
  • --output — Write to file instead of stdout

redirect

Generate redirect rules.

Options:

  • --from — Source path (required)
  • --to — Destination path or URL (required)
  • --type — HTTP status code: 301 (permanent) or 302 (temporary). Default: 301.

rewrite

Generate URL rewrite rules.

Options:

  • --pattern — Regex pattern to match (required)
  • --target — Rewrite target (required)
  • --flags — RewriteRule flags (default: [L,QSA])
  • --condition — RewriteCond to prepend (repeatable)

Feature Details

Security Headers

Adds these headers via mod_headers:

  • X-Frame-Options: SAMEORIGIN — Prevents clickjacking
  • X-Content-Type-Options: nosniff — Prevents MIME sniffing
  • X-XSS-Protection: 1; mode=block — XSS filter
  • Referrer-Policy: strict-origin-when-cross-origin
  • Permissions-Policy: camera=(), microphone=(), geolocation=()
  • Strict-Transport-Security: max-age=31536000; includeSubDomains (when --https)

Caching Rules

Sets expiry times via mod_expires:

  • Images: 1 month
  • CSS/JS: 1 week
  • HTML: 1 hour
  • Fonts: 1 year

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-30 05:26 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

developer-tools

Gog

steipete
Google Workspace 命令行工具,支持 Gmail、日历、云端硬盘、通讯录、表格和文档。
★ 920 📥 185,726
developer-tools

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 666 📥 323,783
productivity

Agent Invoice Generator

johnnywang2001
根据自然语言或结构化数据生成专业的PDF发票,适用于用户请求创建发票、向客户计费或生成收据等场景。
★ 0 📥 647