Table of Contents
Redirects are an essential part of managing your website's SEO and user experience. They ensure visitors are directed to the correct pages, especially after content updates or migrations. This tutorial guides you through setting up redirects using Cloudflare and other popular tools.
Understanding Redirects
A redirect automatically sends visitors from one URL to another. Common types include 301 (permanent) and 302 (temporary). Properly configured redirects help preserve search engine rankings and improve navigation.
Setting Up Redirects with Cloudflare
Cloudflare offers a user-friendly way to manage redirects at the DNS level. Follow these steps to set up redirects:
Step 1: Log in to Cloudflare
Access your Cloudflare dashboard and select your domain.
Step 2: Navigate to Page Rules
Click on the "Page Rules" tab in the top menu.
Step 3: Create a New Page Rule
Click "Create Page Rule" and enter the URL pattern you want to redirect, e.g., http://example.com/old-page.
Step 4: Set the Redirect Action
Select "Forwarding URL" and choose the status code (301 for permanent, 302 for temporary). Enter the destination URL, e.g., http://example.com/new-page.
Step 5: Save and Deploy
Click "Save and Deploy" to activate the redirect. Test it by visiting the old URL to ensure it redirects correctly.
Using .htaccess for Redirects (Apache Servers)
If your website runs on an Apache server, you can set up redirects using the .htaccess file.
Step 1: Access Your Server
Use FTP or your hosting control panel to locate and edit the .htaccess file in your website's root directory.
Step 2: Add Redirect Rules
Insert the following lines to redirect an old URL to a new one:
Redirect 301 /old-page.html http://example.com/new-page.html
Step 3: Save and Test
Save the file and visit the old URL to confirm the redirect works.
Using WordPress Plugins for Redirects
WordPress plugins simplify redirect management without editing server files. Popular options include "Redirection" and "Simple 301 Redirects".
Setting Up with the Redirection Plugin
Install and activate the "Redirection" plugin from the WordPress plugin repository. Navigate to Tools > Redirection to begin.
Add a New Redirect
Enter the source URL path (e.g., /old-post) and the target URL (e.g., https://example.com/new-post). Save your changes.
Best Practices for Redirects
- Use 301 redirects for permanent moves to preserve SEO.
- Test redirects after setup to ensure they work correctly.
- Update internal links to point directly to new URLs when possible.
- Keep redirect rules organized and documented.
Proper redirect management enhances your website's usability and search engine ranking. Choose the method that best fits your hosting environment and technical skills.