RevealTheme logo

مولّد مقتطفات .htaccess

أنشئ قواعد .htaccess الشائعة: فرض HTTPS، إعادة توجيه www، تعيين ترويسات التخزين المؤقت، تفعيل Gzip.

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

كيفية استخدام هذه الأداة

  1. 1

    Open the dropdown and choose the rule you need (for example, Force HTTPS or Gzip compression).

  2. 2

    Read the generated snippet shown in the code box below the dropdown.

  3. 3

    Select the text and copy it, then paste it into your site's .htaccess file.

  4. 4

    Switch the dropdown to a different rule to view another snippet — combine several by pasting them one after another.

ما هو مولّد مقتطفات .htaccess؟

.htaccess هو ملف إعدادات Apache على مستوى المجلد. يتحكم في إعادة كتابة الروابط، وعمليات إعادة التوجيه، والتخزين المؤقت، والضغط، وترويسات الأمان. تستخدم Hostinger ومعظم خدمات الاستضافة المشتركة Apache (أو LiteSpeed المتوافق معه). تغطي هذه المقتطفات الاحتياجات الأكثر شيوعًا.

حالات الاستخدام الشائعة

  • Forcing every visitor onto HTTPS after installing an SSL certificate on a shared Apache or LiteSpeed host.

  • Canonicalizing a domain to either the www or non-www version with a 301 redirect to consolidate SEO signals.

  • Adding a one-year browser cache to static assets so repeat visitors load CSS, JS, and modern image formats from cache.

  • Turning on Gzip compression for text responses to cut transfer size and improve page load time.

  • Hiding the contents of a folder that has no index file by disabling Apache's automatic directory listing.

  • Blocking PHP execution inside a public uploads directory so an attacker can't run a script they managed to upload.

الأسئلة الشائعة

هل يعمل .htaccess على Nginx؟
لا: يستخدم Nginx صيغة الإعدادات الخاصة به. هذه المقتطفات مخصصة لـ Apache/LiteSpeed فقط.
أين أضع ملف .htaccess؟
في جذر موقعك (إلى جانب index.html). تُطبَّق القواعد على ذلك المجلد وعلى جميع مجلداته الفرعية.

أدوات ذات صلة