• EN
    • FR
    • DE
    • IT
    • ES
  • Resellers
  • Affiliate program
  • About us
  • Green hosting
  • Job 7
  • News
  • Support
Infomaniak
infomaniak infomaniak
Infomaniak
  • I want to...
    • Create a website
      • Create a site with WordPress Design a professional site in a few clicks.
      • Create a site with a CMS Create a Joomla, Drupal, PrestaShop, etc., site.
      • Create a site with a Web agency Find your ideal webmaster close to you.
    • Create an email address
      • 1 email free with 1 domain Create a personal email address in Switzerland with the domain of your choice.
      • 5 or more email addresses Create your professional email addresses in Switzerland with the domain of your choice.
    • Store data online
      • kDrive Synchronise, share and work on your Word, Excel and PowerPoint documents online.
      • Swiss Backup Back up your PC, Mac, servers and mobile devices on a secure cloud.
      • NAS Synology Rent a Synology in our secure data centres to manage your data freely.
    • Transfer a domain name
    • Pay an invoice
    Quick actions
    • Compare hosting offers
    • Renew
  • Domains
    • Order Purchase your domain name at the best price.
    • Domain Privacy Protect the private data of your domains in Whois and block spam.
    • Transfer Relocate your domain to Infomaniak.
    • Renewal Warranty Secure your domains against loss and theft.
    • SSL certificates Secure your sites with a Sectigo or Let's Encrypt EV or DV certificate.
    • Fast Anycast DNS New Speed up access to your site from anywhere in the world with just 1 click.
    • DynDNS New Access your connected devices remotely via your domain name.
    Quick actions
    • Renew
    • Prices
    • Whois
    • Our tips
  • Hostings
    • Web & Mail
      • Web + Mail Hosting Create your sites and professional email addresses with our flagship offer.
      • Mail Hosting Create your professional email addresses and sync your contacts and calendars.
      • Web Hosting Create your internet sites (without email).
      • WorkSpace Discover the Swiss webmail for SMEs which synchronises your emails, calendars and contacts.
    • Dedicated and Cloud servers
      • Managed Cloud Server Create your sites with 100% dedicated resources.
      • Unmanaged Cloud Server Create your Linux/Windows server with 100% dedicated resources.
      • Jelastic Cloud Create your bespoke Cloud infrastructure (Java, Node.js, Ruby, Docker, etc.).
      • Very High Availability Hosting Use the same technology as the world's most visited sites (custom SLA).
    • Housing / Datacenter
    Quick actions
    • Compare hosting offers
    • Renew
  • Infomaniak Suite
    • kDrive Infomaniak kDrive Collaborate and share your files wherever you are.
      With Docs, Grids & Points
      docs grids points
    • swisstransfer SwissTransfer.com Send files up to 50 GB free of charge.
    • mail Infomaniak Mail The email service that respects your privacy.
      With Calendar, Contacts & SMS
      calendar contacts sms
    • kMeet Infomaniak kMeet Create online meetings. 100% free and secure.
    • myksuite Infomaniak My kSuite Master the branding of your tools with your domain and logo.
    • kPaste Infomaniak kPaste Share your passwords and private messages with complete security.
    Quick actions
    • Renew
  • Backup and storage
    • Swiss Backup Back up your servers, workstations and files in a datacenter in Switzerland.
    • kDrive Infomaniak kDrive New Collaborate and share your files wherever you are.
    • Synology NAS Rent a NAS in a secure datacenter in Switzerland.
    • swisstransfer SwissTransfer.com Share large files up to 50 GB for free.
    Quick actions
    • Renew
  • Marketing & Events
    • Newsletter Send your newsletters and manage your email marketing with an easy-to-use tool with no subscription.
    • Guest manager Efficiently manage the invitations to your events.
    • E-ticket box office Create your online box office for your professional events (festivals, seminars, etc.).
    Quick actions
    • Renew
  • Multimedia
    • Audio streaming (web radio) Create your online radio and freely monetise your live podcasts, etc.
    • Video streaming (web TV) Create your online TV and freely monetise your live broadcasts.
    • VOD/AOD Easily host and integrate your videos, podcasts, etc. on your site.
    Quick actions
    • Renew
  • Support
    • Knowledge base
    • Contact us
    • Pay a bill
  • Subscription
Sign in
  • Manager login
  • EN
    • FR
    • DE
    • IT
    • ES
  • Subscription
  • Sign in
    • Workspace

      Webmail, contacts, calendar

    • Manager

      Managing Infomaniak products

Knowledge base

1000 FAQs, 500 tutorials and explanatory videos. Here, there are only solutions!

Knowledge base Password-protecting a folder with a .htaccess

    Password-protecting a folder with a .htaccess

    This guide explains how to password-protect a folder by using your site's .htaccess file.

    It is also possible to password-protect a folder in a few clicks with our "directory protection" tool: https://faq.infomaniak.com/68

    1. Get the full pathway of the directory to be protected

    1. log in to your hosting using an FTP client or our FTP Manager
    2. in the folder to be protected, create a file named path.php and copy the following content into it: <?php echo realpath('path.php'); ?>
    3. open a web browser and display the path.ph filep (e.g.: votre-domaine.com/dossier_a_proteger/path.php)
    4. the browser displays the full pathway of the file to be protected. Copy this pathway, we need it for the next step

    2. Password selection and encryption

    1. In the folder to be protected, create a file called password.php and adapt the following content inside it: <?php echo crypt('password of your choice'); ?>
    2. open a web browser and display the password.php file (e.g.: votre-domaine.com/dossier_a_proteger/password.php)
    3. the web browser displays your encrypted password. Copy this encrypted password, we will need it in step 4

    3. Create .htaccess

    In the folder to be protected, create a file called .htaccess and t adapt the following content inside it:

    AuthName "Protected administration page"
    AuthType Basict
    AuthUserFile "/example/.htpasswd"
    Require valid-user

    Replace /example/with the full path copied in step 1 of this guide without path.php at the end. Correct example:

    AuthUserFile "/home/clients/0f83c7afb710e5ae2645a1b704d8772f/web/dossier_a_proteger/.htpasswd"

    4. Create the .htpasswd file

    In the folder to be protected, create a file called htpasswd.txt and adapt the following content inside it:

    login:mot_de_passe_crypté

    • Replace login with the login you require
    • Replace mot_de_passe_crypté with the encrypted password you copied in Step 2 of this guide

    Once the htpasswd.txt file is saved, rename it as follows: .htpasswd

    5. Test

    Open a web browser and try to display one of the pages contained in the protected folder. If the guide has been followed correctly, the login and password (not encrypted) selected will give access to the protected folder.



    Link to this FAQ:
    Has this FAQ been helpful?
    Thank you for your feedback. Improve this FAQ?
    Please do not ask any questions through this form, it is only used to improve our FAQ.
    Please use our contact form for any question.
    Your message has been sent. Thank you for suggesting an improvement to this FAQ.
    Display all FAQs for this product

    Infomaniak

    Blog About us Support Knowledge base Site map General Sales Conditions & Data Policy

    Swiss hosting provider

    Wordpress hosting Web Hosting Mail Hosting Cloud Server / VPS SSL certificates

    Domains

    Register a domain Transfer a domain Whois domain Renewal Warranty Domain Privacy Fast Anycast DNS Report an abuse

    Professional tools

    Synology NAS Newsletter tool Video streaming live Live Audio Streaming Housing and colocation Guest manager

    Green hosting

    Certificates and rewards Environmental commitments
    • swissmade
    • swiss hosting
    • ISO 50001 – Energy Management
    • ISO 14001 - Environmental Management
    • ISO 14001 - Environmental Management
    • Infomaniak
    • Support
    • Knowledge base
    • Password-protecting a folder with a .htaccess
    News
    About us
    Ecological charter
    Join us!
    Your browser is outdated, security and browsability are no longer guaranteed. We recommend that you update it as soon as possible by clicking here.