WordPress

How to Redirect URLs in WordPress Without a Plugin

How to Redirect URLs in WordPress Without a Plugin

Why Set Up Redirects in WordPress?

Redirects are essential for keeping your SEO intact and your visitors happy. Whether you’re fixing broken links, moving content, or restructuring your site, a proper redirect ensures that traffic — and search engine authority — gets passed to the correct page.

While many plugins offer redirect functionality, you can redirect URLs in WordPress manually without adding extra load to your site.


Method 1: Use .htaccess (for Apache Servers)

If your site runs on an Apache server (most shared hosts do), the .htaccess file is the most efficient way to set up redirects.

Steps:

  1. Connect to your server via FTP or use your host’s File Manager
  2. Open the .htaccess file in the root directory of your WordPress site
  3. Add a redirect rule like this, just before # BEGIN WordPress: # Redirect old-page to new-page Redirect 301 /old-page/ https://yourdomain.com/new-page/
  4. Save the file and test the redirect in your browser

Make sure the old URL path is relative (no domain), and the new URL is absolute.


Method 2: Use PHP in functions.php (Basic Redirects)

If you don’t have access to .htaccess or prefer PHP, you can add a redirect directly in your theme’s functions.php file:


function custom_redirect_example() {
  if (is_page('old-page')) {
    wp_redirect(home_url('/new-page/'), 301);
    exit;
  }
}
add_action('template_redirect', 'custom_redirect_example');

This tells WordPress to redirect the user before loading the page. Use this method for occasional or small-scale redirections.


Method 3: Redirect Entire Site (Domain Migration)

If you’ve moved to a new domain and want to redirect everything:


RewriteEngine On
RewriteCond %{HTTP_HOST} ^olddomain\.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www\.olddomain\.com [NC]
RewriteRule ^(.*)$ https://newdomain.com/$1 [L,R=301,NC]

Place this in your old site’s .htaccess file. It sends all traffic to the new domain while preserving URLs.


Tips for Redirecting URLs Safely

  • Use 301 redirects for permanent moves
  • Use 302 redirects for temporary changes
  • Always back up your site before editing .htaccess or functions.php
  • Clear your browser and site cache after setting up redirects

Optional: Use Redirect Check Tools

To confirm your redirect is working, try:


Conclusion

Redirecting URLs in WordPress doesn’t require a plugin. With a few lines of code in .htaccess or functions.php, you can safely manage redirects, speed up your site, and preserve SEO value.

If you’re managing many redirects or want an interface, plugins like Redirection are great — but for clean, fast results, the manual approach works like a charm.