.htaccess مولد
قم بتبديل القواعد التي تحتاجها - فرض عمليات إعادة التوجيه عبر HTTPS أو www أو بدون www، وتعطيل قائمة الدليل، وحظر ملفات النقاط، وتمكين التخزين المؤقت لـ gzip والمتصفح، وصفحات الأخطاء المخصصة، وCORS - واحصل على Apache .htaccess جاهز للاستخدام. نسخ أو تنزيل على الفور.
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
اختر الخيارات
قم بتبديل القواعد التي تحتاجها، مثل فرض ضغط HTTPS أو ضغط gzip.
- 2
مراجعة
يتم تحديث تحديثات .htaccess أثناء تغيير الخيارات.
- 3
نشر
قم بتنزيل الملف إلى جذر موقعك — اختبره على التدريج أولاً.