Redirection helps you improve your site’s browsing experience.
As previously discussed on the wpcrib.com blog, Redirection is the process of sending a user or browser from one URL to another page.
When it comes to managing WordPress users, Redirection plays a vital role in maintaining logged-In users, as well as random traffic from Search Engines or social media websites.
In today’s article, we’ll talk about redirecting logged-in users for security, management, or membership purposes. On the other hand, you can also learn how to redirect random traffic or show proper notifications on browsing specific pages.
Redirecting Logged-In users and random traffic
- Logged-In users: After your site users log in, you can redirect them to the Home page, Dashboard, or any other page specific for respective users. It helps you efficiently manage user community on your WordPress website.
- Random traffic: You can also redirect traffic coming from third-party sources like Google or social media platforms. Once efficiently managed, you can avoid users from seeing your sensitive pages, or let them see their welcome messages.
How to redirect users in WordPress?
There are two ways to redirect WordPress users. You can proceed with any depending on your skills. However, one consists of using a WordPress plugin called the Peter’s Login Redirect, and the second method comprises using HTACCESS file for configuring redirection.
In the following lines, we’re going to address the HTACCESS file first, followed by a method that features the WordPress plugin – Peter’s Login Redirect.
Redirect WordPress users using HTACCESS file
HTACCESS file is a configuration file used in Apache Web Server. You can use HTACCESS for allowing or restricting access to specific locations of a website; or redirecting users to specific pages.
You can also use HTACCESS file for redirecting random traffic. It means that the HTACCESS file is ideal for redirecting random users – having no logged-in session on your WordPress website.
To permanently redirect a page using HTACCESS file, proceed to edit the file, enter the below syntax, and save changes at the end. You can find HTACCESS file at the root of your WordPress website.
Redirect 301 “old-page” “new-page”
Example: Redirect 301 “example.com/old-page.html” “example.com/new-page.html”
Similarly, you can also temporary redirect a page on your website. In this case, enter the following syntax in your site’s HTACCESS file.
Redirect 302 “old-page” “new-page”
Example: Redirect 302 “example.com/old-page.html” “example.com/new-page.html”
If you couldn’t find HTACCESS file at the root of your website, you can proceed to one of our previously compiled articles on using HTACCESS file for WordPress redirection. The said tutorial helps you learn how to create an HTACCESS file on your WordPress website, its benefits, syntax structure and lists common redirect code snippets for beginners.
Redirect WordPress users using Peter’s Login Redirect plugin
First of all, you will need to install and activate the said plugin. Head over to Plugins -> Add New page in Dashboard. Search for Peter’s Login Redirect and install the first plugin that appears in search results.
After activating the plugin, proceed to land on Settings -> Login/logout redirects page. The next page shows redirection options for various conditions like Specific users or roles, all users, or for specific posts.
Once you finish setting up redirects in the Peter’s Login Redirects plugin, you should keep in mind that the plugin acts upon rules for Logged-In users. It means the plugin redirects users as they log into your WordPress website.
At the top of the page, you can choose a user from the list, and put in the destination link in the URL field. The system will redirect the specified user to page you enter in the URL field. Similarly, set in a Logout URL for the user and click on the (Add username rule) button at the end.
Similarly, you can configure redirects for different user roles such as Administrator. Set the proper conditions under Specific Roles and save changes at the end.
In the same manner, you can try out settings for All users, posts, or various user levels. You can also set plugin’s measures at the end of the page.
Make sure to evaluate and set the plugin’s settings properly. Also, you should enter the URLs on the same domain; otherwise, the plugin may not work correctly.
It is effortless to set proper redirects for WordPress users. All you have to do is to set redirects in the HTACCESS file or go for the Peter’s Login Redirects plugin.
As a WordPress web admin, you can use the HTACCESS file to redirect random traffic on your website. When dealing with the said file, you will need to keep track of valid syntax and structure. Comparatively, Peter’s Login Redirect plugin helps you set redirects for logged-in users.
If you’re facing issues finding or creating HTACCESS file in the WordPress, make sure you look for it in the Hosting cPanel -> File Manager -> Root of your website. If for example, you still fail to find the said file; you can use the Yoast SEO plugin to create, edit, and locate HTACCESS file in your WordPress website. Alternatively, you can install Peter’s Login Redirect plugin on the WordPress Plugins Directory.
We hope you liked this article. If you face issues implementing tactics defined in this write-up, proceed to let us know in the comments below. You can also head over to our WordPress Knowledge Base for beginners, as well as for advanced users.