Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

wp-login.php?redirect_to=https problem

Add the below code into your functions.php file

function redirect_login_page()
{
    $login_page = home_url('/login/'); //your redirect page link here
    $page_viewed = basename($_SERVER['REQUEST_URI']);

    if ($page_viewed == "wp-login.php" && $_SERVER['REQUEST_METHOD'] == 'GET') {
        wp_redirect($login_page);
        exit;
    }
}
add_action('init', 'redirect_login_page');

Related Posts:

  1. Changing user_nicename
  2. How to turn off redirection from ‘domain.com/login’ to ‘domain.com/wp-login.php’
  3. PHP If user is logged in & on home page redirect
  4. Is it necessary to sanitize wp_set_password user input?
  5. Problem with login form
  6. How to redirect users based on role and content of redirect_to?
  7. Lost in trying to create user database system
  8. Infinite loop when logging out using custom login form
  9. Need help with AJAX login to call php in functions.php to handle redirects based on user cap (role)
  10. Redirect users not logged in to the standard login page (and back) from some posts and pages
  11. wp_login_url always redirects me to wp-admin
  12. wp-login – unable to redirect user to a custom login url
  13. Redirect to current URL and append specified URL parameter on unsuccessful login through Elementor login form widget
  14. How to save checkbox values for logged in users?
  15. wp search-replace on database returns PHP fatal error: Array and string offset access syntax with curly braces is no longer supported
  16. How does WordPress know wich language is chosen when there is a database connection error
  17. Programmatic Login from 3rd Party site
  18. Cannot access wp-admin/wp-login.php (WordPress backend) anymore, what could be wrong?
  19. WordPress homepage infinite redirect
  20. How to debug my custom login form looping intermittently
  21. How can I save unique user data on my site? [closed]
  22. Redirect undesirable domain
  23. Is it possible to create a wordpress database with php code?
  24. Update results, Before deleting the related category [closed]
  25. Store a default value for a transient on plugin activation
  26. getting logged in user info (wp-load.php) from parent directory
  27. How WordPress reacts to a lack of memory of the server [closed]
  28. Split reads to a different connection string
  29. custom user role wordpress – grant guest access to edit.php without insert/update/delete
  30. Execute long and heavy processes
  31. Dynamic content in template
  32. database sent to a JSON file
  33. How do I display the main domain for my WordPress install?
  34. inserting a post from an extern php file but post content doesn’t show on wp site
  35. Login to wordpress by clicking a link and specifying usernaname and password in url
  36. Using custom tables for old posts
  37. Databases – Submitting data from inputs to database [closed]
  38. db converts decimal number wrong
  39. Not connecting to database in file with multiple MySQL connections
  40. Log in / Log Out Custom Button
  41. Set Cache-Control header for 301 redirects
  42. Should `wp_login` be used since it’s deprecated?
  43. Moving code from theme header to functions.php
  44. Change CSS based on is_user_logged_in
  45. How to display login form anywhere, when user isn’t logged in, without redirecting?
  46. Filtering a Database Query
  47. How can I open up my administrative panel to everyone?
  48. Showing latest post without 301 redirect
  49. Having Issue on Redirecting With Session in WordPress
  50. Display Data in Table from External Database in WP using Shortcodes
  51. Is it best to avoid using $wpdb for security issues?
  52. How can I import an excel column into wordpress database?
  53. Blob file download problem
  54. WordPress Block developer from exporting Database via PHP
  55. How to retrieve the data from the sever and displaying it in a page?
  56. Using a $GET parameter from a URL, to redirect to a URL (WordPress)
  57. Execute a function every hour in the background
  58. Create page with custom php script and fetched data
  59. wpdb prepare insert table doesn’t work
  60. Should I use WordPress to skin a database website?
  61. How do I display offsite database info on my wordpress site?
  62. Creating Database Table vs. Adding MetaData to Post & User
  63. WordPress and MySQL: trying to print data using PHP from user_meta custom field data
  64. Building a REST API for your web app exposes primary keys of DB records?
  65. WordPress redirect redirecting too many times or not at all
  66. Most commented posts by time period (last 12h, last 24h and etc)
  67. Using Argument from Function to Re-Direct Visitor (WordPress)
  68. I am receiving a pluggable.php warning sign on my only http:// page
  69. How can I add a new row in a separate database when someone registers via WordPress?
  70. Login redirect. Check user meta and redirect accordingly
  71. Where to insert redirect code based on http_referer?
  72. Saving data from custom form in wordpress database
  73. Is this a correct usage of ob_start() in my WordPress project?
  74. How can I find the cause of a 500 server error?
  75. How to allow download url redirection only if user logged in WordPress site?
  76. I can’t update my data through $wpdb
  77. wpdb Cannot Update column in Database
  78. Can’t successfully check if post with title exist in database
  79. Cant connect to database with php 7.3
  80. One account with multiple logins
  81. Delete database record using plugin from admin panel
  82. How to get image from url from the database?
  83. Set default Database Storage Engine when creating tables with plugins?
  84. Wpdb get->results to out the the month from the db
  85. Filter results from a serialized string to use on statistics
  86. How to add data to a custom field at the wp_users table?
  87. Creating custom page template from existing PHP site
  88. Shortcode to log user into current URL
  89. wordpress site – using custom database and PHP
  90. PHP Redirect condition
  91. Get wp_current_user_id using PHP and MySQL
  92. PHP getting error when trying to access WP-Admin Dashboard
  93. I installed WordPress locally now how do I login?
  94. If user is logged in not working
  95. WPDB – Read and write value from / to database
  96. How do I make this Metabox show current DB value?
  97. Change homepage content if user is logged in – BuddyPress
  98. Manually Create PHP Page For A Redirect
  99. How to Generate a list of Most Commented post?
  100. Why when I create a new post I found 2 record related to this post into the posts database table?
Categories PHP Tags database, login, php, redirect
Unable to create a new taxonomy
Adding styles/scripts to specific page

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress