When it comes to setting up an online store, WooCommerce is one of the most popular choices for WordPress users. While it’s a fairly straightforward platform to use, there are still a few things that can trip up new users. One of those things is changing the default login URL.
The default login URL for WooCommerce is /my-account/. This is fine if you don’t have anything else going on with your website that would require a /my-account/ URL. However, if you do have something else using that URL (like a membership site), then you’ll need to change the WooCommerce login URL to avoid any conflicts.
Changing the WooCommerce login URL is actually pretty easy to do.
There are two methods you can use:
- Change it via the WordPress admin dashboard
- Change it via your theme’s functions.php file
We’ll walk you through both methods so you can choose the one that’s best for you.
Method 1: Change the Login URL Via the WordPress Admin Dashboard
This method is best for those who are comfortable working with code and don’t mind doing a little bit of research. We’ll be using the WordPress Rewrite API to add a new rewrite rule that will change the WooCommerce login URL.
First, you need to connect to your WordPress site via FTP and edit your theme’s functions.php file.
Once you have access to your functions.php file, add this code snippet:
function wc_change_login_url() {
add_rewrite_rule(
'^my-account$',
'index.php?wc_login=true',
'top'
);
}
add_action( 'init', 'wc_change_login_url' );
Make sure to save your changes and upload the file back to your server. Once that’s done, head back over to your WordPress admin area and go to Settings » Permalinks and click on the Save Changes button.
This will flush the rewrite rules and update your .htaccess file with the new rewrite rule we just added in functions.php.
Method 2: Change the Login URL Via Your Theme’s Functions.php File
If you’re not comfortable working with code or don’t want to mess with any of the under-the-hood settings in WordPress, then this method is for you.
All you need to do is add this one line of code to your theme’s functions.php file:
define( 'WC_LOGIN_URL', home_url() );
Be sure to save your changes and upload the file back to your server..