{"id":1531,"date":"2019-02-08T10:35:56","date_gmt":"2019-02-08T10:35:56","guid":{"rendered":"https:\/\/blog.hostinger.io\/support\/2019\/02\/08\/1583316-how-to-add-a-login-form-to-a-website-in-hostinger\/"},"modified":"2026-03-16T12:12:17","modified_gmt":"2026-03-16T12:12:17","slug":"1583316-how-to-add-a-login-form-to-a-website-in-hostinger","status":"publish","type":"post","link":"https:\/\/www.hostinger.com\/support\/1583316-how-to-add-a-login-form-to-a-website-in-hostinger\/","title":{"rendered":"How to Add a Login Form to a Website in Hostinger"},"content":{"rendered":"<p class=\"no-margin\">If you want to have more control over who reaches your website&rsquo;s content, you can implement a login form. This way, a password will be required to provide access to your website or parts of it.<\/p><p class=\"no-margin\">\n<\/p><p class=\"no-margin\">Let&rsquo;s go through different ways how it can be achieved: <\/p><ul>\n<li>\n<p class=\"no-margin\">With the help of the <b><a href=\"#option-1---hpanel\" target=\"_blank\" class=\"intercom-content-link\">Password Protect Directories<\/a><\/b> feature<\/p>\n<\/li>\n<li>\n<p class=\"no-margin\">Using a <b><a href=\"#option-2---wordpress-plugin\" target=\"_blank\" class=\"intercom-content-link\">WordPress plugin<\/a><\/b><\/p>\n<\/li>\n<li>\n<p class=\"no-margin\">With <b><a href=\"#option-3---htaccess\" target=\"_blank\" class=\"intercom-content-link\">.htaccess<\/a><\/b><\/p>\n<\/li>\n<\/ul><p class=\"no-margin\">\n<\/p><h2 id=\"option-1---hpanel\">Option 1 &ndash; Password Protect Directories<\/h2><div class=\"intercom-interblocks-callout\" style=\"background-color: #e3e7fa80;border-color: #334bfa33\">\n<p class=\"no-margin\">If you use <b>Hostinger Website Builder<\/b>, refer to this article instead: <b><a href=\"\/support\/6899183-website-builder-how-to-password-protect-a-page\" target=\"_blank\" class=\"intercom-content-link\">Website Builder: How to Password-Protect a Page<\/a> &#128161;<\/b><\/p>\n<\/div><p class=\"no-margin\">One of the easiest ways is to enable the <b><a href=\"\/support\/1583470-how-can-i-password-protect-my-website\" target=\"_blank\" class=\"intercom-content-link\">Password Protect Directories<\/a> <\/b>feature for your website.<\/p><p class=\"no-margin\">\n<\/p><p class=\"no-margin\">This option allows you to protect all of your website or just one directory without the need to edit any code &#128522; <\/p><p class=\"no-margin\">\n<\/p><h2 id=\"option-2---wordpress-plugin\">Option 2 &ndash; WordPress Plugin<\/h2><div class=\"intercom-interblocks-callout\" style=\"background-color: #e3e7fa80;border-color: #334bfa33\">\n<p class=\"no-margin\">This option is not available if you use <b>Hostinger Website Builder<\/b> &#128161; <\/p>\n<\/div><p class=\"no-margin\">If your website is WordPress-based, you can use a plugin such as <b><a href=\"https:\/\/wordpress.org\/plugins\/wordfence\/\" target=\"_blank\" class=\"intercom-content-link\" rel=\"noopener\">WordFence<\/a> <\/b>to enable two-factor authentication (2FA) or add a <b><a href=\"https:\/\/www.hostinger.com\/tutorials\/what-is-recaptcha\" target=\"_blank\" class=\"intercom-content-link\">captcha<\/a><\/b> feature to prevent bots from attempting to log in to your website.<\/p><p class=\"no-margin\">\n<\/p><p class=\"no-margin\">There are other plugins that can help you limit access to registered users only, such as <b><a href=\"https:\/\/wordpress.org\/plugins\/wp-force-login\/\" target=\"_blank\" class=\"intercom-content-link\" rel=\"noopener\">Force Login<\/a><\/b>.<\/p><p class=\"no-margin\">\n<\/p><h2 id=\"option-3---htaccess\">Option 3 &ndash; .htaccess<\/h2><div class=\"intercom-interblocks-callout\" style=\"background-color: #e3e7fa80;border-color: #334bfa33\">\n<p class=\"no-margin\">This option is not available if you use <b>Hostinger Website Builder<\/b> &#128161; <\/p>\n<\/div><p class=\"no-margin\">If you feel comfortable coding, you can add the login form by a<b> .htaccess file<\/b> in the directory you want to protect. <\/p><p class=\"no-margin\">\n<\/p><p class=\"no-margin\">First, check if the directory you want to protect has a <b>.htaccess<\/b> file, or you can <b><a href=\"\/support\/1583307-how-to-create-an-htaccess-file\" target=\"_blank\" class=\"intercom-content-link\">create one<\/a> <\/b>if needed. For example, to protect your complete website, place it in the <b>public_html<\/b> folder.<\/p><p class=\"no-margin\">\n<\/p><p class=\"no-margin\">You will also need to create a file named .<b>htpasswd<\/b> that can be anywhere on your account. For safety reasons, it is recommended that the <b>.htaccess<\/b> and <b>.htpasswd<\/b> files be stored in different folders.<\/p><p class=\"no-margin\">\n<\/p><p class=\"no-margin\">Once you have created the <b>.htpasswd<\/b> file, add to it the following line:<\/p><pre><code>username:password<\/code><\/pre><p class=\"no-margin\">Replacing <code>username<\/code> and <code>password<\/code> with your desired values.<\/p><p class=\"no-margin\">\n<\/p><p class=\"no-margin\">Go back to the <b>.htaccess<\/b> file and insert these lines:<\/p><pre><code>AuthType Basic<br>AuthName \"Authorization required\"<br>AuthUserFile \/path\/to\/.htpasswd<br>require valid-user<\/code><\/pre><p class=\"no-margin\">Where  <code>\/path\/to\/.htpasswd<\/code> is the actual path where the <b>.htpasswd<\/b> file will be located. For your Hostinger account, if the file is inside a subfolder of your domain, it would look similar to this: <\/p><p class=\"no-margin\"><code>\/home\/u123456789\/domains\/domain.tld\/public_html\/subfolder\/.htpasswd <\/code><\/p><p class=\"no-margin\">That&rsquo;s it! Your website will be password protected &#128522;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Requiring visitors to log in before accessing the website<\/p>\n","protected":false},"author":581,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"include_on_kodee":true,"footnotes":""},"categories":[274],"tags":[],"class_list":["post-1531","post","type-post","status-publish","format-standard","hentry","category-website-development"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/support\/1583316-how-to-add-a-login-form-to-a-website-in-hostinger\/","default":1},{"locale":"fr-FR","link":"https:\/\/www.hostinger.com\/fr\/support\/1583316-comment-ajouter-un-formulaire-de-connexion-a-votre-site-web-hostinger\/","default":0},{"locale":"id-ID","link":"https:\/\/www.hostinger.com\/id\/support\/1583316-bagaimana-cara-menambahkan-form-login-ke-website-saya-di-hostinger\/","default":0},{"locale":"pt-PT","link":"https:\/\/www.hostinger.com\/br\/support\/1583316-como-adicionar-um-formulario-de-login-ao-seu-site-na-hostinger\/","default":0},{"locale":"uk-UA","link":"https:\/\/www.hostinger.com\/ua\/support\/1583316-------hostinger\/","default":0}],"include_on_kodee":true,"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/1531","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/users\/581"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/comments?post=1531"}],"version-history":[{"count":0,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/1531\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/media?parent=1531"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/categories?post=1531"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/tags?post=1531"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}