Introduction
Managing redirects is a crucial aspect of website maintenance and SEO. A 301 redirect permanently moves a webpage to a new location, ensuring that both users and search engines are directed to the correct page. We will create 301 redirects to prevent issues with SEO. This guide will walk you through various methods of creating 301 redirects using:
.htaccessfiles for Apache servers- Nginx configuration
- Content Management Systems (CMS) like WordPress, Drupal, and Joomla!
Table of Contents
- Introduction
- Understanding 301 Redirects
- Create 301 Redirects in .htaccess (Apache)
- Create 301 Redirects in Nginx
- Create 301 Redirects in WordPress
- Create 301 Redirects in Drupal
- Create 301 Redirects in Joomla!
- Conclusion
- Need Assistance?
- Additional Resources
Understanding 301 Redirects
A 301 redirect signals to browsers and search engines that a page has permanently moved to a new URL. It helps in:
- Preserving SEO rankings
- Enhancing user experience by avoiding 404 errors
- Consolidating duplicate content
Create 301 Redirects in .htaccess (Apache)
The .htaccess file is a configuration file used by the Apache web server. It allows for decentralized management of web server configuration.
Steps:
- Access the .htaccess File Locate the
.htaccessfile in your website's root directory. If it doesn't exist, create a new one. - Basic 301 Redirect Syntax
Redirect 301 /old-page.html https://www.example.com/new-page.html
- Redirect an Entire Site
Redirect 301 / https://www.newsite.com/
- Using RewriteEngine for Complex Redirects Enable the RewriteEngine:
RewriteEngine On
Redirect from old URL to new URL:
RewriteRule ^old-page/?$ https://www.example.com/new-page/ [R=301,L]
Important Notes:
- Ensure that mod_rewrite is enabled on your Apache server.
- Backup your
.htaccessfile before making changes.
Apache Official Documentation:
Create 301 Redirects in Nginx
Nginx uses server configuration blocks, and redirects are placed within these blocks.
Steps:
- Access the Nginx Configuration File Usually located at
/etc/nginx/nginx.confor within the/etc/nginx/sites-available/directory. - Basic 301 Redirect Syntax
server {
listen 80;
server_name www.example.com;
return 301 https://www.example.com$request_uri;
}
- Redirect Specific Page
location /old-page {
return 301 https://www.example.com/new-page;
}
- Redirect Using Rewrite
rewrite ^/old-page/?$ https://www.example.com/new-page permanent;
Important Notes:
- Test the configuration before reloading Nginx:
sudo nginx -t
- Reload Nginx to apply changes:
sudo systemctl reload nginx
Nginx Official Documentation:
Create 301 Redirects in WordPress
WordPress is a popular CMS that offers several ways to implement redirects.
Method 1: Using Plugins
Recommended Plugin: Redirection
- Steps:
- Install and activate the Redirection plugin.
- Navigate to Tools > Redirection.
- Add a new redirect by specifying the Source URL and Target URL.
Method 2: Editing Functions.php
- Steps:
- Access your theme's
functions.phpfile. - Add the following code:
function custom_redirect() { if (is_page('old-page')) { wp_redirect('https://www.example.com/new-page', 301); exit(); } } add_action('template_redirect', 'custom_redirect');
WordPress Official Website:
Create 301 Redirects in Drupal
Drupal provides modules and configuration options for handling redirects.
Method 1: Using the Redirect Module
- Steps:
- Install the Redirect module.
- Enable the module via Extend in the admin panel.
- Navigate to Configuration > Search and Metadata > URL redirects.
- Add a new redirect by entering the From and To URLs.
Method 2: Using .htaccess
- Similar to Apache's
.htaccessmethod since Drupal often runs on Apache servers.
Drupal Official Website:
Create 301 Redirects in Joomla!
Joomla! offers built-in functionality as well as extensions for redirects.
Method 1: Using the Redirect Manager
- Steps:
- Enable the Redirect plugin:
- Go to Extensions > Plugins.
- Search for System - Redirect and enable it.
- Access the Redirect Manager:
- Navigate to Components > Redirect.
- Add a new redirect:
- Click New and enter the Expired URL and New URL.
Method 2: Using Extensions
- Recommended Extension: ReDJ
- Install the ReDJ extension.
- Follow the extension's documentation to set up redirects.
Joomla! Official Website:
Conclusion
Implementing 301 redirects is essential for maintaining SEO value and ensuring a smooth user experience when URLs change. Whether you're using Apache, Nginx, or a CMS like WordPress, Drupal, or Joomla!, the methods outlined above will help you set up effective redirects.
Need Assistance?
If you find this process complicated or need professional assistance, we're here to help! Contact us at help4network.com/contact.php to become one of our clients. Our experts can handle the technical details for you.
Additional Resources
- Apache Documentation: Apache HTTP Server Project
- Nginx Documentation: Nginx.org
- WordPress Plugins: WordPress Plugin Directory
- Drupal Modules: Drupal Module Repository
- Joomla! Extensions: Joomla! Extensions Directory
Author Information
This article was written by an experienced web developer specializing in server configuration and CMS management.
Hosting maintenance note
Redirects are easy to add and easy to stack into loops. Before changing production routing, list the old URL, the final destination, expected status code, cache layer, and rollback path. Test with cache bypassed first, then confirm the public edge follows the same route.
Before changing a live site or server, capture the current configuration, confirm recent backups, and decide how you will roll back if the change affects logins, checkout, forms, cron jobs, or customer traffic. For shared hosting, make changes during a window where you can watch logs and customer-facing pages.
Post-change verification
- Validate the server or application configuration before reloading services.
- Test the exact workflow the change was meant to improve.
- Clear only the cache layers needed for the test, then retest from the public edge.
- Review logs for warnings, permission errors, failed requests, or unexpected redirects.
Related hosting performance reading
- Current Redis WHM/cPanel install guide
- Current Memcached WHM/cPanel install guide
- Current Imagick WHM/cPanel guide
- Current Imagick Linux hosting guide
- WordPress performance optimization guide
- WordPress speed tips
- How To Install And Enable redis For WHM/cPanel AlmaLinux 8
- How To Install Imagick on WHM/cPanel (CentOS 7 or AlmaLinux 8)
2026 redirect planning refresh
A 301 redirect should map an old URL to the closest useful replacement, not just send every missing page to the homepage. Before a migration, export current URLs, mark the pages that must keep search value, and decide which pages should redirect, return 404, or return 410 because there is no replacement.
After changing redirects, test the final public URL, canonical tag, sitemap entry, HTTP status, mixed-content behavior, form flow, and analytics path from outside the admin session. On hosting accounts, keep a rollback copy of .htaccess, Nginx server blocks, CMS redirect plugin settings, and CDN redirect rules before editing.
Related Fix I.T. Phill reading
- Fix WordPress 404 errors and redirects
- Sitemaps and 404 errors SEO checklist
- Move a domain to a new host safely
