简体   繁体   中英

WordPress redirecting from example.com/login to example.com/wp-login.php - how to change it?

How can I change default redirection in WordPress from /login to /wp-login.php ? - I don't want that redirection. I want to have something else at example.com/login but I can't find it in WordPress, and I don't want lost it during updates. I will be also grateful for some link to codex if there something that can helps me ;)

Edit:

I want to install something different than WordPress in folder login under address example.com/login , but WordPress automatically redirecting me from example.com/login to example.com/wp-login.php . I don't want that - I want see content from example.com/login .

Paste this within your .htaccess file on your project root. Also must be placed on top of Wordpress Rewriterules.

RewriteRule ^login/?$ wp-login\.php [R=301,L]

Full code:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteRule ^login/?$ wp-login\.php [R=301,L]

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Make sure you don't have any post/page with slug name login .

Edited:

If you need to map the URL instead of redirect just remove R=301 flag.

RewriteRule ^login/?$ wp-login\.php [L]

Also if you want to see the login in URL after logged out. Place this function in your functions.php file of your theme.

add_action('wp_logout', 'login_redirect');

function login_redirect() {
    wp_redirect(site_url( 'login' ));
    exit;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM