सीधे कॉन्टेंट पर जाएँ

सूचना पाएँ

नई बड़ी सुरक्षा घटना होने पर ईमेल पाएँ। स्पैम नहीं, कभी भी सदस्यता रद्द करें।

इसका इस्तेमाल सिर्फ pwn.watch की घटना-संबंधी ईमेल के लिए होता है। Cloudflare Turnstile से सुरक्षित।

← pwn.watch के सभी सुरक्षा टूल

.htaccess जनरेटर: रीडायरेक्ट, HTTPS और सुरक्षा हेडर

Apache .htaccess फ़ाइल बनाएँ: HTTPS लागू करें, www या बिना www चुनें, 301 रीडायरेक्ट जोड़ें, HSTS / CSP / X-Frame-Options हेडर सेट करें, हॉटलिंकिंग और IP ब्लॉक करें, और कैशिंग व gzip चालू करें।

Quick security presets

HTTPS और कैननिकल होस्ट

301 रीडायरेक्ट

→

पुराना पाथ / से शुरू होना चाहिए। लक्ष्य: पाथ या पूरा https:// URL।

सिक्योरिटी हेडर

ज़्यादा सख़्त CSP चाहिए? CSP जनरेटर से बनाएँ।

एक्सेस कंट्रोल और सुरक्षा मज़बूती

परफ़ॉर्मेंस

.htaccess

# Generated by pwn.watch/tools/htaccess-generator

# ----- Hardening -----
Options -Indexes
<FilesMatch "^\.(?!well-known)">
  Require all denied
</FilesMatch>
<FilesMatch "\.(bak|config|sql|ini|log|sh|swp|dist)$">
  Require all denied
</FilesMatch>

# ----- HTTPS, www & rewrite rules (mod_rewrite) -----
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
  RewriteRule ^ https://%1%{REQUEST_URI} [L,R=301,NE]
  RewriteCond %{HTTPS} off
  RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
</IfModule>

# ----- 301 redirects (mod_alias) -----
Redirect 301 /old-page /new-page

# ----- Security headers (mod_headers) -----
<IfModule mod_headers.c>
  Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains" "expr=%{HTTPS} == 'on'"
  Header always set Content-Security-Policy "default-src 'self'; frame-ancestors 'self'; object-src 'none'; base-uri 'self'"
  Header always set X-Frame-Options "SAMEORIGIN"
  Header always set X-Content-Type-Options "nosniff"
  Header always set Referrer-Policy "strict-origin-when-cross-origin"
  Header always set Permissions-Policy "camera=(), microphone=(), geolocation=()"
  Header unset X-Powered-By
</IfModule>

# ----- Brotli compression (mod_brotli) -----
<IfModule mod_brotli.c>
  AddOutputFilterByType BROTLI_COMPRESS text/html text/plain text/css text/xml text/javascript
  AddOutputFilterByType BROTLI_COMPRESS application/javascript application/json application/xml application/rss+xml image/svg+xml
</IfModule>

# ----- Gzip compression (mod_deflate) -----
<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml text/javascript
  AddOutputFilterByType DEFLATE application/javascript application/json application/xml application/rss+xml image/svg+xml
</IfModule>

# ----- Browser caching (mod_expires) -----
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresDefault "access plus 1 hour"
  ExpiresByType text/html "access plus 0 seconds"
  ExpiresByType text/css "access plus 1 year"
  ExpiresByType application/javascript "access plus 1 year"
  ExpiresByType image/webp "access plus 1 year"
  ExpiresByType image/avif "access plus 1 year"
  ExpiresByType image/png "access plus 1 year"
  ExpiresByType image/jpeg "access plus 1 year"
  ExpiresByType image/svg+xml "access plus 1 year"
  ExpiresByType font/woff2 "access plus 1 year"
</IfModule>

इनकी ओर सेTinkerer Club

उन लोगों का निजी क्लब जिनके अपने सर्वर हैं, जो अपना AI चलाते हैं और सॉफ़्टवेयर के लिए $0/महीना देते हैं।

.htaccess FAQ

.htaccess से HTTPS कैसे ज़रूरी करें?
mod_rewrite चालू करें और जोड़ें: RewriteEngine On, RewriteCond %{HTTPS} off, RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]। प्रॉक्सी या लोड बैलेंसर के पीछे हों, तो %{HTTPS} की जगह %{HTTP:X-Forwarded-Proto} जाँचें।
.htaccess में 301 रीडायरेक्ट कैसे लिखें?
एक पाथ के लिए mod_alias इस्तेमाल करें: Redirect 301 /old-page /new-page। पूरा डोमेन बदलने के लिए पुराने होस्ट पर RewriteCond %{HTTP_HOST} और RewriteRule ^(.*)$ https://new.example/$1 [L,R=301] के साथ mod_rewrite इस्तेमाल करें।
.htaccess में कौन-से सुरक्षा हेडर सेट करने चाहिए?
Strict-Transport-Security (HSTS), Content-Security-Policy, X-Frame-Options या CSP frame-ancestors, X-Content-Type-Options: nosniff, Referrer-Policy और Permissions-Policy। इनके लिए mod_headers चाहिए। HSTS तभी चालू करें, जब हर सबडोमेन HTTPS पर काम करे।
डायरेक्टरी लिस्टिंग कैसे बंद करें?
Options -Indexes जोड़ें। Apache तब बिना index फ़ाइल वाले फ़ोल्डर की सामग्री दिखाने के बजाय 403 लौटाता है।
मेरी .htaccess फ़ाइल काम क्यों नहीं कर रही?
vhost में overrides की अनुमति होनी चाहिए (AllowOverride All, या कम-से-कम FileInfo, Options, AuthConfig, Limit), और इस्तेमाल किए गए मॉड्यूल (mod_rewrite, mod_headers, mod_expires, mod_deflate) लोड होने चाहिए। Nginx .htaccess को पूरी तरह अनदेखा करता है।
क्या कुछ सर्वर पर भेजा जाता है?
नहीं। फ़ाइल आपके ब्राउज़र में तैयार होती है; आपके लिखे हुए कुछ भी अपलोड नहीं होता।