[英]How to programmatically hide the wp-login.php in Wordpress?
I managed to create the /login url to redirect me in /wp-login.php page我设法创建 /login url 以在 /wp-login.php 页面中重定向我
In my .httacces I have the following code在我的 .httacces 我有以下代码
RewriteRule ^login$ wp-login.php [NC,L]
In the functions.php (in my custom theme) I added this在functions.php(在我的自定义主题中)我添加了这个
add_filter('site_url', 'wplogin_filter', 10, 3);
function wplogin_filter( $url, $path, $orig_scheme )
{
$old = array( "/(wp-login\.php)/");
$new = array( "login");
return preg_replace( $old, $new, $url, 1);
}
The problem is how to disallow access to wp-login.php page without disabling it.问题是如何在不禁用它的情况下禁止访问 wp-login.php 页面。 With the solution above both url's are visible /login and /wp-login.php使用上面的解决方案,两个 url 都是可见的 /login 和 /wp-login.php
How can I "hide" the wp-login.php permenantly without usign a plugin?如何在不使用插件的情况下永久“隐藏” wp-login.php?
I once used this in my .httaccess file.我曾经在我的 .httaccess 文件中使用过它。
Code:代码:
<Files "whatever.php">
require all denied
require host localhost
require ip 127.0.0.1
require ip xxx.yyy.zzz.aaa
</Files>
This prevents any external entry to whatever.php这可以防止任何外部进入whatever.php
You don't really have to hide it.你真的不必隐藏它。 Just redirect access to the home page - or any other page.只需将访问重定向到主页 - 或任何其他页面。
add_filter( 'login_url', 'my_redirect_login', 10, 3 );
function my_redirect_login(){
if ($_SERVER['REQUEST_URI']!='/wp-login.php') return;
header( 'Location: '.home_url(null, 'https') );
exit;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.