انتقل إلى المحتوى

الدروس cPanel مبتدئ1 دقائق قراءة

How to Password-Protect a Directory in cPanel

Lock a folder, staging site or admin area behind a username and password using cPanel Directory Privacy or .htaccess and .htpasswd.

بواسطة فريق تحرير ZSOLNET آخر تحديث

هذه الصفحة غير متاحة بالعربية بعد، لذا تُعرض بالإنجليزية.

أهم النقاط

  • Directory Privacy adds HTTP basic authentication to a folder.
  • It's ideal for staging sites and private downloads.
  • Always combine it with HTTPS so the password isn't sent in clear text.

With Directory Privacy

  1. In cPanel, open Files → Directory Privacy.
  2. Click the folder name to navigate, then Edit next to the folder you want to protect.
  3. Tick Password protect this directory and give it a name (shown in the login prompt).
  4. Click Save.
  5. Under Create User, add a username and a strong password, then Save.

Visiting the folder now shows a browser login box.

With .htaccess (any Apache server)

Create the password file outside the public folder:

htpasswd -c /home/username/.htpasswds/staging alice

Then add to .htaccess in the folder:

AuthType Basic
AuthName "Staging"
AuthUserFile /home/username/.htpasswds/staging
Require valid-user

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

Will Google index a password-protected folder?

No. Crawlers can't log in, so protected pages aren't indexed. That makes it a good way to keep staging sites out of search results.

Can I protect WordPress's wp-admin this way?

Yes, but exclude admin-ajax.php, which some front-end features call. Many prefer two-factor login instead.

شارك X LinkedIn Facebook

الدخول إلى حسابك

أدِر نطاقاتك واستضافتك وفواتيرك من مكان واحد.

اتصال آمن مباشرة مع منطقة العملاء في ZSOLNET.

ليس لديك حساب؟