मुख्य सामग्री पर जाएँ
घर.htaccess जेनरेटर

.htaccess जेनरेटर

आपके लिए आवश्यक नियमों को टॉगल करें - HTTPS, www या गैर-www रीडायरेक्ट को बाध्य करें, निर्देशिका सूची को अक्षम करें, dotfiles को ब्लॉक करें, gzip और ब्राउज़र कैशिंग, कस्टम त्रुटि पेज और CORS को सक्षम करें - और उपयोग के लिए तैयार Apache .htaccess प्राप्त करें। तुरंत कॉपी करें या डाउनलोड करें.

100% क्लाइंट-साइड · कोई भी डेटा आपके ब्राउज़र को नहीं छोड़ता

Force HTTPS

Redirect all HTTP traffic to HTTPS

Disable directory listing

Hide folder contents (Options -Indexes)

Block dotfiles

Deny access to .env, .git, etc.

Gzip compression

Compress text responses

Browser caching

Cache static assets

Custom error pages

404.html / 500.html

CORS: allow all origins

Access-Control-Allow-Origin: *

<IfModule mod_rewrite.c>
  RewriteEngine On
  # Force HTTPS
  RewriteCond %{HTTPS} off
  RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>

# Disable directory listing
Options -Indexes

# Block access to dotfiles (.env, .git, etc.)
<FilesMatch "^\.">
  Require all denied
</FilesMatch>

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

# Browser caching
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType image/jpeg "access plus 1 year"
  ExpiresByType image/png "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"
</IfModule>

Tip: place this file in your site's root. Test on staging first — a bad rule can take a site offline.

.htaccess फ़ाइल कैसे बनायें

रीडायरेक्ट, प्रदर्शन और सुरक्षा के लिए Apache .htaccess नियम बनाएं।

  1. 1

    विकल्प चुनें

    आपके लिए आवश्यक नियमों को टॉगल करें, जैसे Force HTTPS या gzip संपीड़न।

  2. 2

    समीक्षा

    जैसे ही आप विकल्प बदलते हैं .htaccess अपडेट लाइव हो जाते हैं।

  3. 3

    तैनात करना

    फ़ाइल को अपनी साइट रूट पर डाउनलोड करें - पहले स्टेजिंग पर परीक्षण करें।