Can’t log out from Woocommerce when I redirect wp-login to home

Rate this post

Since all users including admin can log in through the my-account page of Woocommerce, I was thinking that redirecting wp-login.php to homepage would be a good idea for an extra layer of security. so I put the following code in .htaccess:

Redirect /wp-login.php

but when I click on the logout link of Woocommerce, it redirects everyone to homepage instead of logging out:

Is there any chance to block wp-login.php and only use my-account page for logging in and out?




As per OP’s comments adding this solution now, where in condition I am looking that query string to wp-login.php shouldn’t have logout action to redirect it to login page.

RewriteCond %{QUERY_STRING} !action=logout
RewriteCond %{REQUEST_URI} ^/wp-login\.php/?$
RewriteRule ^(.*)$ http://%{HTTP_HOST}

Leave a Reply

Your email address will not be published.

Back to top button