ToolHub
中文
Light
GitHub
返回首页
/
安全编码
/
.htaccess 生成器
加载中...
配置选项
域名
强制 HTTPS
GZIP 压缩
浏览器缓存
自定义错误页
防盗链
www 重定向
不设置
移除 www
添加 www
屏蔽 IP (每行一个)
自定义重定向 (每行: /from /to)
/old-page /new-page /blog/old /blog/new
.htaccess
复制
# Force HTTPS RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # Remove www RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^(.*)$ https://%1/$1 [R=301,L] # Enable GZIP Compression <IfModule mod_deflate.c> AddOutputFilterByType DEFLATE text/html text/plain text/css AddOutputFilterByType DEFLATE text/javascript application/javascript application/json AddOutputFilterByType DEFLATE text/xml application/xml image/svg+xml </IfModule> # Browser Caching <IfModule mod_expires.c> ExpiresActive On ExpiresByType image/jpg "access plus 1 year" ExpiresByType image/jpeg "access plus 1 year" ExpiresByType image/png "access plus 1 year" ExpiresByType image/gif "access plus 1 year" ExpiresByType image/svg+xml "access plus 1 year" ExpiresByType text/css "access plus 1 month" ExpiresByType application/javascript "access plus 1 month" ExpiresByType text/html "access plus 1 day" </IfModule> # Custom Error Pages ErrorDocument 404 /404.html ErrorDocument 403 /403.html ErrorDocument 500 /500.html # Custom Redirects Redirect 301 /old-page /new-page Redirect 301 /blog/old /blog/new