November 16, 2020

How to password protect your wordpress domain using .htaccess and cPanel

Using .htaccess file you can easily hide and protect your wordpress site from search engines and users. First of all you should create two files .htpasswd and .htaccess in your root directory. In first file you will store the user and password for your password protected area and the second file is using to create a server rule to enable password authentication or password protection. You can create it easily from your cPanel File Manager here:

The next step will be to edit .htpasswd file and add there username and password separated with “:”, example:

user_here:password_here

The code above will allow the user to access the password protected area with the selected username and password. You can add as many users as you like, one per line, so feel free to add as many combinations as you like.

The last step is to edit .htaccess file and add there this rule:

AuthType Basic
AuthName "This is a Protected Area"
AuthUserFile root/path/to/.htpasswd
Require valid-user

Don’t forget to “Save” the changes!

After all the steps you can check the changes by accessing your domain from the browser window. If you did everything properly you will see the popup window with required username and password.

 

In case you need help in support your website from professionals, you can choose one of our WordPress Care Plans. Our CodaStudio team take care of everything on your website from small design changes to custom functionality.

About the author

Ivan is a CodaStudio lead wordpress developer. He also manages a web design company at Elivan Studio. He likes to sneak in a few games of World of Tanks, and is a huge Harry Potter movie fan.

Subscribe to our newsletter


Privacy Preference Center

Necessary

These cookies are required to provide necessary site functionalities and features.

wordpress_[hash], wordpress_logged_in_[hash], wp-settings-{time}-[UID], wordpress_test_cookie, wp_woocommerce_session_, wpe-auth, woocommerce_cart_hash, woocommerce_items_in_cart, gdpr[consent_types], __distillery, gdpr[allowed_cookies], time, muxData, fs_uid, ajs_user_id, _gid, __cfduid, intercom-id-x51ganuz, ajs_group_id, ajs_anonymous_id, _ga, __jid, cp-impression-added-forcp_id_, disqus_unique, nelioab_was_in, nelioab_env, nelioab_userid, mp_a36067b00a263cce0299cfd960e26ecf_mixpanel, _ga, intercom-lou-x51ganuz, __stripe_mid

Third Party

Learn more about Types of Cookies used by Google: https://policies.google.com/technologies/types

Learn more about Google Analytics Cookies: https://developers.google.com/analytics/devguides/collection/analyticsjs/cookie-usage

Learn more about Facebook Cookies: https://www.facebook.com/policies/cookies/

Learn more about Intercom Cookies: https://www.intercom.com/terms-and-policies#cookie-policy

NID,1P_JAR,DV, OTZ, SID, APISID, SSID, HSID, SAPISID, OGPC, AID, SIDCC, HSID, IDE, _ym_uid, __sonar, DSID, FR, dpr, datr, c_user, xs, wd, act, sb, presence, disqus_unique, hubspotutk, G_ENABLED_IDPS, __hstc, btIdentify, _bti, __utma, __utmz, __hssrc, sessionid, _ga, _gid, intercom-id-x2byp8hg, __simplex, _sp_id., __hstc, optimizelyEndUserId, _ga, _gid, hubspotutk, __ar_v4, __hssrc, wistia-http2-push-disabled, intercom-id-, intercom-session-, gtm_id, messenger_install_identifier, _ga, product_store_identifier, intercom-lou-, _hp2_id., _drip_client_, fs_uid, amplitude_idsegment.com, ajs_user_id, mkjs_group_id, mkjs_user_id, _ga, _ga, seg_xid_ts, seg_xid_fd, __ar_v4, seg_xid, ajs_anonymous_id, AID, _ga, optimizelyEndUserId, fs_uid
NID,1P_JAR,DV, OTZ, SID, APISID, SSID, HSID, SAPISID, OGPC, AID, SIDCC, HSID
IDE, _ym_uid, __sonar, DSID
FR, dpr, datr, c_user, xs, wd, act, sb, presence
disqus_unique, hubspotutk, G_ENABLED_IDPS, __hstc, btIdentify, _bti, __utma, __utmz, __hssrc, sessionid, _ga, _gid, intercom-id-x2byp8hg
__simplex, _sp_id., __hstc, optimizelyEndUserId, _ga, _gid, hubspotutk, __ar_v4, __hssrc, wistia-http2-push-disabled
intercom-id-, intercom-session-, gtm_id, messenger_install_identifier, _ga, product_store_identifier, intercom-lou-, _hp2_id.
_drip_client_, fs_uid, amplitude_idsegment.com, ajs_user_id, mkjs_group_id, mkjs_user_id, _ga, _ga, seg_xid_ts, seg_xid_fd, __ar_v4, seg_xid, ajs_anonymous_id
AID
_ga, optimizelyEndUserId, fs_uid