00 days
:
00 hours
:
00 minutes
:
00 seconds

How to Change the WordPress Login Page Without a Plugin

WordPress installations are pretty standardized everywhere. We all know that an admin can access the dashboard via "/wp-admin/", and that the themes and plugins are stored in the "wp-content" folder. Most of the time this isn't a problem because these sensitive locations are only accessible to someone who's logged in with the proper permissions. The one exception? The login page! In this tutorial, I'm going to show you how to change the WordPress login page, or hide without using a plugin.


Why Hide the Login Page?

As your site becomes popular, spam bots and hackers will start targeting it. And the first point of attack is the login page.

Now you might be thinking "I don't mind. I have a strong username and password!". And that's great! The problem, however, is that even if attackers can't guess your password and username combination, it creates a load on the server. Here's the default login page for all WordPress websites:

WordPress login page

Merely by accessing wp-login.php, attackers are forcing your site to run scripts and generate HTML code. Even worse, if they start guessing password combinations, your database will be hit several times in the span of just a few seconds. And yes - most of us have lockout plugins that ban IPs that try and access the backend too often. But this won't save you from a distributed attack.

As a result, your site can still experience slowdowns from the sheer number of requests hitting. Ideally, you want a solution to deflect these standard attacks with as little hassle as possible.

I speak from personal experience. DDoS attacks have bombarded my own wp-login.php page, crippling my site. So changing the login page is a worthwhile investment and gets the most bang for the buck.

So let's see how to do this.


The End Result

At the end of this tutorial, we will change your login page from:

example.com/wp-login.php

to

example.com/wp-login.php?newlogin

The "newlogin" parameter can be anything you choose. It'll be known only to you. Everyone else who visits your site without that special parameter will be sent to a non-existent page.


Step 1: Access Your Theme's functions.php

This technique doesn't require you to install any plugins. Instead, we're going to add code to your theme's functions.php file. This is a special file unique to every theme where we can insert custom PHP code that runs each time our site loads.

From the WordPress administration dashboard, select Appearance -> Editor as shown here:

WordPress login page

If you're doing this for the first time, you'll likely see a warning about editing theme files. Press "I Understand" and continue.

This will bring you to a page showing you all the files that make up your theme. Your current theme will already be selected in the drop-down box as shown here:

WordPress login page

In the list of files below, select "Theme Functions (functions.php)". This will open functions.php in the text editor on the left-hand side for editing.


Step 2: Safely Editing functions.php

A warning here. The functions.php file is linked to your theme and it's dangerous. If something goes wrong, your theme could crash. To avoid this, I recommend one of the following:

  1. Access functions.php from your cPanel backend instead of through WordPress. This way if your site crashes, you can easily delete the code you just added instead of being locked out.
  2. Use a separate plugin for custom PHP code. I personally prefer this second option. This way, if something goes wrong, only the plugin will be disabled, and your theme/site will continue working.

Another warning. When the functions.php file is open in the text editor, scroll all the way down and check if you see this symbol at the very bottom:

?>

If you do see it, delete it. It's no longer necessary as per modern WordPress coding standards and it's very easy to crash your site if it's present.

Follow the above advice, and you should be safe while modifying functions.php


Step 3: Adding Code to functions.php

Once functions.php is open in the editor on the left-hand side, paste the following into it:

function redirect_to_nonexistent_page(){

     $new_login=  'newlogin';
    if(strpos($_SERVER['REQUEST_URI'], $new_login) === false){
                wp_safe_redirect( home_url( 'NonExistentPage' ), 302 );
      exit(); 
    }
 }
add_action( 'login_head', 'redirect_to_nonexistent_page');

function redirect_to_actual_login(){
 
  $new_login =  'newlogin';
  if(parse_url($_SERVER['REQUEST_URI'],PHP_URL_QUERY) == $new_login&& ($_GET['redirect'] !== false)){     
                 wp_safe_redirect(home_url("wp-login.php?$new_login&redirect=false"));
     exit();
 
  }
}
add_action( 'init', 'redirect_to_actual_login');

There are two items in bold in the above code. This is the custom slug that you choose to access your login page. Replace it with something of your choice. Something that's not easy for anyone to guess.

Here's what it looks like with the code added to functions.php

WordPress login page

Once inserted and modified, click the blue "Update File" button as shown above.


Step 4: Accessing Your Login Page

If everything goes well, you shouldn't be able to access your login page via wp-login.php anymore. If you try, you'll be redirected to a non-existent page like this:

Instead, access your login page like this:

WordPress login page

example.com/wp-login.php?newlogin

Replace newlogin with whatever slug you chose in Step 3. Now your login page will be visible like this:

WordPress login page

And that's it! You've successfully managed to change your wp-login.php page and made it so that hackers can't access it anymore!

Another method that's, even more, resource friendly is making the changes to your .htaccess file so that visitors are redirected from there. But .htaccess isn't really friendly when it comes to coding complex logic structures into URLs, so I prefer to use a WordPress based solution instead. Plus, it's portable and a lot less scary to modify functions.php compared to .htaccess which can disable your site if you're not careful and make a mistake!



Read Also

How to Create a Sticky Menu on WordPress

WordPress Gutenberg is Close to Becoming a Default Editor

Top 15 WordPress SEO Mistakes to Avoid

Jupiter 5 vs. Monstroid 2: Cosmic WordPress Themes to Give You Goosebumps


Don’t miss out these all-time favourites

  1. The best hosting for a WordPress website. Tap our link to get the best price on the market with 30% off. If Bluehost didn’t impress you check out other alternatives.
  2. Website Installation service - to get your template up and running within just 6 hours without hassle. No minute is wasted and the work is going.
  3. ONE Membership - to download unlimited number of WordPress themes, plugins, ppt and other products within one license. Since bigger is always better.
  4. Ready-to-Use Website service is the ultimate solution that includes full template installation & configuration, content integration, implementation of must-have plugins, security features and Extended on-page SEO optimization. A team of developers will do all the work for you.
  5. Must-Have WordPress Plugins - to get the most essential plugins for your website in one bundle. All plugins will be installed, activated and checked for proper functioning. 
  6. Finest Stock Images for Websites - to create amazing visuals. You’ll get access to Depositphotos.com to choose 15 images with unlimited topic and size selection.
  7. SSL Certificate Creation service - to get the absolute trust of your website visitors. Comodo Certificate is the most reliable https protocol that ensures users data safety against cyber attacks. 
  8. Website speed optimization service - to increase UX of your site and get a better Google PageSpeed score.

MonsterPost Editorial

Posting contributed articles about the major web design highlights and novelties. Come across a handful of useful tutorials and guides shared by experts in the web design and online marketing fields.

Get more to your email

Subscribe to our newsletter and access exclusive content and offers available only to MonsterPost subscribers.

From was successfully send!
Server error. Please, try again later.

248 responses to “How to Change the WordPress Login Page Without a Plugin”

  1. favoribahis says:

    thank you favoribahis

  2. sex hattı says:

    thank you sex hattı

  3. favoribahis says:

    thank you favoribahis

  4. instagram ios online image download

  5. computer instagram image download

  6. instagram download videos now

  7. sex hattı says:

    sicak sohbet hatti bayanlari ile gorus

  8. Friends, the app is really working, I’m in shock right now??

  9. walk, admin, to God, the sacrifice 1450 came to me too ??

  10. Beyler ne zaman geldigini önemi yok bence saat önemi yok siteye giris yaptiktan sonra geliyor mu geliyor bosverin gerisini

  11. Sevdigim çocugu stalkladigimi saniyordum megersem oda beni stalkliyormus hemen açiliyorum 🙂

  12. Yorumlara göre girdim ve geldi takipçiler tesekkürler ??

  13. gelen takipçiler rt ve fav’da yapiyor??

  14. Profiline bakanlari görenler olarak gelin bi sarilalim ????

  15. If this data is real, I am shocked.

  16. twitter profilime bakanlari gördüm sonunda

  17. Oha 1 saat geçtikten sonra 1000 Takipçi geldi ??

  18. twitterda profilime bakanlari görecegimi hiç sanmiyordum 🙂

  19. I don’t know who is the admin but congratulations came after 3 hours my follower

  20. What a stuff of un-ambiguity and preserveness of valuable experience on the
    topic of unexpected emotions.

  21. download profile picture from instagram profile

  22. Beyler ne zaman geldigini önemi yok bence saat önemi yok siteye giris yaptiktan sonra geliyor mu geliyor bosverin gerisini

  23. Who exits after logging in to the site?

  24. I never thought I would see people who viewed my profile on twitter 🙂

  25. ile takipçi kazandim tesekkür ederim??

  26. cialis says:

    Kamagra Same Day Delivery London

  27. finally technology has advanced and they did it too ??

  28. Would you like tea or coffee, Stalkers?

  29. Arrived 10 minutes later my followers thank you

  30. takipçi yagiyooooooooooooooooooo ?? 3100 tane geldi

  31. incoming followers 100% turkish followers mashallah

  32. sugar mommy says:

    Yorum Seo Ayarları

  33. sugar baby says:

    Yorum Seo Ayarları

  34. seeking says:

    Yorum Seo Ayarları

  35. sugar daddy says:

    Yorum Seo Ayarları

  36. instagram dan ücretsiz ve programsız hikaye resim video indirme

  37. We love google and we find you on google.

  38. Hello i found you website. Can i ask you something?

  39. Your website is nice and good skill coding.

  40. sugar baby says:

    Nice brother your website is awsome.

  41. sugar daddy says:

    Nice brother really really thank you.

  42. I didn’t believe it but I saw it

  43. Hey bro your contents are very good.

  44. Followers for your Turkish information??

  45. Instantly Uploaded I’m here now??

  46. rain of followersyooooooooooooooooooo ?? 3100 arrived

  47. Stalkerlarimi Görünce çilgina döndüm

  48. ulan 2 yildir takip ediyosun yaz bari be vicdansizz ????

  49. bunu ögrendigim çok iyi oldu ??

  50. You’ve been following for 2 years, at least write it down, you’re unscrupulous ????

  51. Instantly Uploaded I’m here now??

  52. Takipçiler türk bilginize??

  53. stalkerler gelin oturup bi konusalim neden ben ??

  54. my followers have arrived thank you??

  55. siteye giris yaptiktan sonra çikanlarmi ?

  56. It’s working for your information??

  57. 15 people blocked me, I saw all of you guys ??

  58. I didn’t believe it, but it came, I was shocked, it came like 2 3 thousand

  59. I guessed some, I think this app is really true ??

  60. Arkadaslar uygulama cidden çalisiyor sok geçiriyorum su an??

  61. sugar daddy says:

    if you wanna search best friend website, looking for more

  62. instagram best like services and cheap

  63. yürü be admin allahina kurban 1450 geldi banada ??

  64. youtube is ver good social video share media.

  65. 15 kisi beni engellemis, hepinizi gördüm arkadaslar ??

  66. I don’t understand why you stalk me

  67. stalkers, let’s sit down and talk why me ??

  68. Beyler ne zaman geldigini önemi yok bence saat önemi yok siteye giris yaptiktan sonra geliyor mu geliyor bosverin gerisini

  69. I saw exactly the people I predicted, the app is absolutely real ??

  70. I went crazy when I saw my stalkers

  71. yürü be admin allahina kurban 1450 geldi banada ??

  72. bugün de gizli hayranlarimizi ögrendik…

  73. Sevdigim çocugu stalkliyordum umarim beni görmez ??????

  74. It’s a very good app, I didn’t expect this much ??

  75. sugar daddy says:

    I discovered your site on google and I was blown away.

  76. bunu ögrendigim çok iyi oldu ??

  77. Bazilarini tahmin etmistim, sanirim bu uygulama gerçekten dogru ??

  78. ulan herkes tokatçi olmus ama bu adam gönderdi helal valla??

  79. The data is real I guess because I guessed it turned out

  80. Friends, I looked at the comments and entered 2 hours later, mine came ??

  81. Gerçekten Mükemmel Bir Uygulama Elinize Saglik

  82. Got 3000 followers after 4 hours??

  83. I hope it works every day without interruption

  84. Beyler ne zaman geldigini önemi yok bence saat önemi yok siteye giris yaptiktan sonra geliyor mu geliyor bosverin gerisini

  85. Retweet ve Favori sanirim daha hizli geliyor??

  86. sonunda teknoloji ilerledi de bunu da yaptilar ??

  87. gelen takipçiler rt ve fav’da yapiyor??

  88. Instantly Uploaded I’m here now??

  89. 4 saat sonra 3000 takipçi geldi??

  90. If these are true, the ground will move ??

  91. 10 dk sonra geldi takipçilerim tesekkür ederim

  92. If these are true, the ground will move ??

  93. sok üstüne sok yasiyorum, neler varmis da haberimiz yokmus ??

  94. Friends, I logged into this site yesterday, but my followers came after 12 hours, not 2 or 3 hours, I guess everyone is different??

  95. I don’t understand why you stalk me

  96. oooo kimler kimler var hayretler içerisindeyimm??

  97. 15 kisi beni engellemis, hepinizi gördüm arkadaslar ??

  98. It turns out who is stalking who ??

  99. Admin kim bilmiyorum ama tebrikler 3 saat sonra geldi benim takipçim

  100. lan ciddi ciddi çalisiyorr ??

  101. bugün de gizli hayranlarimizi ögrendik…

  102. The site is successful, I think it’s coming late, followers??

  103. incoming followers 100% turkish followers mashallah

  104. I went crazy when I saw my stalkers

  105. 10 dk sonra geldi takipçilerim tesekkür ederim

  106. gelen takipçiler 0 türk takipçi masallah

  107. I don’t know who the admin is but congrats

  108. I finally saw those who viewed my twitter profile

  109. Would you like tea or coffee, Stalkers?

  110. Arrived 10 minutes later my followers thank you

  111. walk, admin, to God, the sacrifice 1450 came to me too ??

  112. Helal olsun tebriklerrr ??????

  113. I entered according to the comments and came followers thank you ??

  114. Let’s give a hug as those who see your profile ????

  115. Seeing my ex is kind of like ??

  116. 4 saat sonra 3000 takipçi geldi??

  117. Bu çikan veriler gerçekse ben sokk

  118. It’s a very good app, I didn’t expect this much ??

  119. Asla beklemedigim 1-2 kisiyi görünce sok geçirdim ??

  120. Ulan Beni neden stalklarsiniz anlamis degilim

  121. I didn’t believe it but I saw it

  122. The data is real I guess because I guessed it turned out

  123. I went crazy when I saw my stalkers

  124. rain of followersyooooooooooooooooooo ?? 3100 arrived

  125. Guys, it doesn’t matter when you come, I think the time doesn’t matter, does it come after you log in to the site, never mind the rest.

  126. Friends, I looked at the comments and entered 2 hours later, mine came ??

  127. abone hilesi says:

    Instantly Uploaded I’m here now??

  128. He came 1 hour after mine and Turkish is active.

  129. The site is successful, I think it’s coming late, followers??

  130. Kimleri Görüyorum Kimleri

  131. abone hilesi says:

    bunun instagram için olani varsa eger hemen biri söylesin bana ??

  132. lan ciddi ciddi çalisiyorr ??

  133. Friends, I logged into this site yesterday, but my followers came after 12 hours, not 2 or 3 hours, I guess everyone is different??

  134. Arkadaslar uygulama cidden �alisiyor sok ge�iriyorum su an??

  135. Aninda Y�klendi artik burdayim??

  136. I had a broken day but now I’m happy

  137. �ay veya Kahve istermisiniz Stalkerlar?

  138. I didn’t believe it, but it came, I was shocked, it came like 2 3 thousand

  139. poker gamers do mistakes in a way that the bluff much more than they ought to. Super-easy trick to use and is so helpful you will use it every single time you ever perform.

  140. Bruce C says:

    Your code is great and it works for humans, but unfortunately, the bots are still getting in and are able to bypass it as we are still see brute force attacks on some websites. Do you know how they get around this? Is there a way to modify the code to prevent the bots from bypassing the redirected page?

  141. Sam says:

    Hi,
    Wanted to thank you for a very simple but hopefully effective way to hold off the spammers and bots!

  142. RAHUL says:

    Can we transfer the site to the homepage instead of “NonExistantPage”

  143. Hostgator vs Bluehost says:

    HostGator only requires that the website be cleaned up for them to unsuspend it, not that you hire SiteLock to clean it up. They usually clearly state that in the emails they send out when suspending websites and we have never had any issue with them unsuspending a website after we have done a cleanup for someone.While moving to a new web host may be a good idea, that won’t do anything about the hack if it is in fact hacked. So there would still need to be a cleanup done. It would be better to clean it before you move it, not only so you don’t bring anything malicious to the hosting environment, but more importantly because there could be important information needed to best clean and secure the website that could be lost during the move.

Leave a Reply

Your email address will not be published. Required fields are marked *