<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Oleksandr Chumak</title>
    <description>The latest articles on DEV Community by Oleksandr Chumak (@webhelpagency).</description>
    <link>https://dev.to/webhelpagency</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4021541%2F1adbc1a3-5aef-47a4-897c-2684e3c44f8e.jpg</url>
      <title>DEV Community: Oleksandr Chumak</title>
      <link>https://dev.to/webhelpagency</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/webhelpagency"/>
    <language>en</language>
    <item>
      <title>WordPress 301 Redirects Without a Plugin</title>
      <dc:creator>Oleksandr Chumak</dc:creator>
      <pubDate>Wed, 08 Jul 2026 14:41:30 +0000</pubDate>
      <link>https://dev.to/webhelpagency/wordpress-301-redirects-without-a-plugin-5d6m</link>
      <guid>https://dev.to/webhelpagency/wordpress-301-redirects-without-a-plugin-5d6m</guid>
      <description>&lt;p&gt;A page moves, a slug changes, or a whole site migrates to a new domain — and suddenly every old link is a 404. Redirects fix that instantly, but most tutorials only show you the plugin route, which adds another dependency to a site that's already carrying too many.&lt;/p&gt;

&lt;p&gt;You don't need a plugin for most redirects. WordPress and your server already have everything required — you just need the right code in the right file. Below is exactly how to do it, when a plugin genuinely earns its place, and how to avoid the chains and loops that quietly wreck SEO.&lt;/p&gt;

&lt;p&gt;How do you create a 301 redirect in WordPress without a plugin?&lt;br&gt;
There are two native ways to redirect a URL in WordPress without installing anything:&lt;/p&gt;

&lt;p&gt;Edit your .htaccess file (Apache servers) — fastest, happens before WordPress even loads.&lt;br&gt;
Add a snippet to functions.php — useful when you want redirect logic tied to conditions WordPress understands (user role, post type, query variables).&lt;br&gt;
Both produce a real, crawlable 301 response. Neither requires plugin overhead. Pick .htaccess for simple one-to-one URL swaps; pick functions.php when the redirect depends on WordPress logic rather than just the URL string.&lt;/p&gt;
&lt;h2&gt;
  
  
  How do you redirect via .htaccess?
&lt;/h2&gt;

&lt;p&gt;Your .htaccess file sits in your site's root directory, right next to wp-config.php. Back it up before editing — one typo here can take the whole site down.&lt;/p&gt;

&lt;p&gt;For a single page:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Redirect 301 /old-page/ https://example.com/new-page/&lt;/code&gt;&lt;br&gt;
For an entire folder or category moving to a new path, use RedirectMatch with a pattern instead of listing every URL:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;RedirectMatch 301 ^/old-category/(.*)$ /new-category/$1&lt;/code&gt;&lt;br&gt;
For more control — wildcards, query strings, conditional logic — use mod_rewrite:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;RewriteEngine On&lt;br&gt;
RewriteRule ^blog/tag/(.*)$ /blog/category/$1 [R=301,L]&lt;/code&gt;&lt;br&gt;
Placement matters. WordPress writes its own rewrite block into .htaccess, bookended by # BEGIN WordPress and # END WordPress. Your custom redirects should sit above that block, so they're evaluated before WordPress's own routing takes over:&lt;/p&gt;

&lt;p&gt;`# Custom redirects — added manually&lt;br&gt;
Redirect 301 /old-page/ &lt;a href="https://example.com/new-page/" rel="noopener noreferrer"&gt;https://example.com/new-page/&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  BEGIN WordPress
&lt;/h1&gt;

&lt;p&gt;&lt;br&gt;
RewriteEngine On&lt;br&gt;
RewriteBase /&lt;br&gt;
RewriteRule ^index.php$ - [L]&lt;br&gt;
RewriteCond %{REQUEST_FILENAME} !-f&lt;br&gt;
RewriteCond %{REQUEST_FILENAME} !-d&lt;br&gt;
RewriteRule . /index.php [L]&lt;br&gt;
&lt;/p&gt;

&lt;h1&gt;
  
  
  END WordPress`
&lt;/h1&gt;

&lt;p&gt;Editing .htaccess to add a 301 redirect above the WordPress rewrite block&lt;/p&gt;

&lt;h2&gt;
  
  
  How do you create a redirect using functions.php?
&lt;/h2&gt;

&lt;p&gt;When the redirect needs to check something WordPress-specific — a query variable, a logged-in user, a custom post type — .htaccess isn't the right tool. Hook into template_redirect instead:&lt;/p&gt;

&lt;p&gt;`&lt;br&gt;
function whla_custom_redirects() {&lt;br&gt;
    $redirect_map = [&lt;br&gt;
        'old-page'     =&amp;gt; '/new-page/',&lt;br&gt;
        'old-service'  =&amp;gt; '/services/new-service/',&lt;br&gt;
    ];&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$request_path = trim( parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH ), '/' );

if ( isset( $redirect_map[ $request_path ] ) ) {
    wp_safe_redirect( home_url( $redirect_map[ $request_path ] ), 301 );
    exit;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;}&lt;br&gt;
add_action( 'template_redirect', 'whla_custom_redirects' );&lt;br&gt;
`&lt;br&gt;
A few details that matter here:&lt;/p&gt;

&lt;p&gt;Always pass the status code explicitly ( 301) to wp_safe_redirect() — WordPress defaults to 302 if you omit it, which is the single most common cause of a redirect not passing SEO value the way you expect.&lt;br&gt;
Always call exit; after the redirect, or WordPress will keep rendering the original page alongside the redirect header.&lt;br&gt;
This approach is fine for a handful of redirects. Once you're past 15–20 entries, a flat PHP array becomes hard to maintain — that's the point where a plugin or .htaccess rules make more sense.&lt;br&gt;
What about Nginx?&lt;br&gt;
If your host runs Nginx instead of Apache, .htaccess does nothing — Nginx redirects live in the server block, and changes require a config reload (something your host or dev handles, since most managed WordPress Nginx setups don't give shell access).&lt;/p&gt;

&lt;p&gt;`location = /old-page/ {&lt;br&gt;
    return 301 /new-page/;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;location ~* ^/old-category/(.*)$ {&lt;br&gt;
    return 301 /new-category/$1;&lt;br&gt;
}`&lt;br&gt;
Nginx redirects execute earlier in the request cycle than either of the WordPress-side methods, which makes them the fastest option — but also the one requiring server access most site owners don't have day to day.&lt;/p&gt;

&lt;p&gt;301 vs 302 vs 307/308 — which one when?&lt;br&gt;
Picking the wrong status code is the most common redirect mistake we see on client sites. Each one tells search engines and browsers something different:&lt;/p&gt;

&lt;p&gt;Code    Meaning What it signals Use it when&lt;br&gt;
301&lt;/p&gt;

&lt;p&gt;Permanent&lt;/p&gt;

&lt;p&gt;Transfers link equity to the new URL; browsers and search engines cache it long-term&lt;/p&gt;

&lt;p&gt;The old URL is gone for good — renamed page, merged content, domain migration&lt;/p&gt;

&lt;p&gt;302&lt;/p&gt;

&lt;p&gt;Temporary&lt;/p&gt;

&lt;p&gt;Search engines generally keep indexing the original URL&lt;/p&gt;

&lt;p&gt;A short-term test, maintenance mode, or A/B variant&lt;/p&gt;

&lt;p&gt;307&lt;/p&gt;

&lt;p&gt;Temporary, method-preserving&lt;/p&gt;

&lt;p&gt;Same as 302, but guarantees the request method (GET/POST) isn't changed&lt;/p&gt;

&lt;p&gt;Temporary redirects involving form submissions&lt;/p&gt;

&lt;p&gt;308&lt;/p&gt;

&lt;p&gt;Permanent, method-preserving&lt;/p&gt;

&lt;p&gt;Same as 301, but guarantees the request method isn't changed&lt;/p&gt;

&lt;p&gt;Permanent redirects where the original request was a POST&lt;/p&gt;

&lt;p&gt;For nearly all WordPress redirect scenarios — moved pages, changed slugs, site migrations — 301 is the right default. Reach for 302/307 only when the change is genuinely temporary.&lt;/p&gt;
&lt;h2&gt;
  
  
  How do you redirect with a plugin?
&lt;/h2&gt;

&lt;p&gt;Manual redirects work well for a handful of URLs. Beyond that, a dedicated plugin like Redirection (free) or Yoast SEO Premium's redirect manager earns its keep.&lt;/p&gt;

&lt;p&gt;Green flags for using a plugin:&lt;/p&gt;

&lt;p&gt;You're managing 20+ redirects and need a searchable interface, not a growing PHP array&lt;br&gt;
You need automatic 404 logging to catch broken links you didn't know existed&lt;br&gt;
Non-developers on your team need to add redirects without touching code&lt;br&gt;
You're migrating dozens or hundreds of URLs and want CSV bulk import&lt;br&gt;
Red flags — skip the plugin:&lt;/p&gt;

&lt;p&gt;You have fewer than a dozen redirects total (a few lines of .htaccess is faster and adds zero overhead)&lt;br&gt;
The site is already plugin-heavy and performance-sensitive&lt;br&gt;
The redirect is permanent infrastructure, not something that needs a UI to manage&lt;br&gt;
Both Redirection and Yoast Premium support regex patterns and CSV import, which makes them the practical choice for large-scale migrations rather than hand-writing hundreds of RedirectMatch rules.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnl5qui9vup5ikp83wz0p.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnl5qui9vup5ikp83wz0p.webp" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Comparing manual .htaccess redirects versus a WordPress redirect plugin dashboard&lt;/p&gt;
&lt;h2&gt;
  
  
  How do you redirect after changing a slug or migrating your site?
&lt;/h2&gt;

&lt;p&gt;A single slug change is simple — WordPress will offer to create the redirect for you if you use the built-in URL change prompt, but it's not guaranteed to catch every case, so verify it manually with the .htaccess or plugin methods above.&lt;/p&gt;

&lt;p&gt;A full website migration or restructure is a different scale of problem. Before you touch DNS or go live on a new domain:&lt;/p&gt;

&lt;p&gt;Export a full URL list from your old site (Screaming Frog or your XML sitemap both work).&lt;br&gt;
Build a mapping table — old URL → new URL — for every page, post, and category that's changing.&lt;br&gt;
Convert the mapping into redirect rules — bulk-imported into a plugin, or generated as RedirectMatch patterns if the URL structure changed predictably (e.g., /old-category/ becomes /new-category/).&lt;br&gt;
Test every rule before launch, not after — see the testing section below.&lt;br&gt;
Update internal links in your content to point directly at the new URLs rather than relying on the redirect chain to carry the traffic.&lt;br&gt;
This is exactly the kind of detail work that's easy to under-scope on a DIY migration. If you'd rather hand this off, our WordPress website migration service handles the full URL mapping and redirect setup as part of the move.&lt;/p&gt;
&lt;h2&gt;
  
  
  How do you test redirects and avoid chains or loops?
&lt;/h2&gt;

&lt;p&gt;Never assume a redirect works because it "looks right" in the code — verify it with curl:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;curl -I https://example.com/old-page/&lt;/code&gt;&lt;br&gt;
A working 301 returns something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="k"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt; &lt;span class="m"&gt;301&lt;/span&gt;
&lt;span class="na"&gt;location&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;https://example.com/new-page/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you see a 200 where you expected a 301, the rule isn't matching. If you see more than one Location: header across repeated requests, you've likely created a redirect chain — Old URL → Middle URL → Final URL — which slows the browser down and dilutes the SEO value passed along. Fix it by pointing every step directly at the final destination.&lt;/p&gt;

&lt;p&gt;A redirect loop (A → B → A) is worse — the browser will eventually give up and show an error. These usually happen when a plugin rule and a manual .htaccess rule conflict, or when www and non- www versions of a rule redirect into each other. Always test the full chain after any migration or bulk redirect import, not just a sample.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fson6gd7xfjjxo7bnkd6s.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fson6gd7xfjjxo7bnkd6s.webp" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Testing a WordPress 301 redirect with curl -I in the terminal&lt;/p&gt;

&lt;p&gt;How does redirecting affect SEO, and how long should you keep 301s?&lt;br&gt;
A correctly implemented 301 passes the substantial majority of the original page's ranking signals to the new URL — Google has said as much for years, and in practice sites we've migrated retain their rankings within days to a few weeks once the new URLs are crawled and indexed.&lt;/p&gt;

&lt;p&gt;Keep 301s in place indefinitely. Removing them once traffic to the old URL "looks quiet" is a common mistake — old backlinks, bookmarks, and cached search results can send visitors to that URL for years. If you're doing a broader overhaul rather than a single redirect, our &lt;a&gt;website redesign SEO checklist&lt;/a&gt; covers the rest of what needs to survive a redesign intact — redirects included.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently Asked Questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  How do I do a 301 redirect in WordPress without a plugin?
&lt;/h3&gt;

&lt;p&gt;Add a Redirect 301 or RewriteRule line to your site's .htaccess file (Apache), or hook a redirect into template_redirect in functions.php using wp_safe_redirect() with a 301 status code. Both methods work without installing anything.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do you create a redirect URL in WordPress?
&lt;/h3&gt;

&lt;p&gt;Decide on the old path and the new destination, then add a matching rule in .htaccess ( Redirect 301 /old-path/ /new-path/), in functions.php, in your Nginx config, or through a redirect plugin — the method depends on your server and how many redirects you need to manage.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do you redirect a page using .htaccess in WordPress?
&lt;/h3&gt;

&lt;p&gt;Open .htaccess in your site's root folder, add a Redirect 301 or RewriteRule line above the # BEGIN WordPress block, and save. Test immediately with curl -I to confirm the response is a 301 pointing at the correct new URL.&lt;/p&gt;

&lt;h3&gt;
  
  
  What's the difference between a 301 and a 302 redirect?
&lt;/h3&gt;

&lt;p&gt;A 301 tells browsers and search engines the move is permanent and transfers the original page's SEO value to the new URL. A 302 signals a temporary change, and search engines typically keep the original URL indexed rather than replacing it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Do I need a plugin to redirect URLs in WordPress?
&lt;/h3&gt;

&lt;p&gt;No. .htaccess, Nginx config, and functions.php can all handle redirects natively. A plugin like Redirection or Yoast Premium becomes worth installing once you're managing dozens of redirects, need 404 logging, or want a non-developer to manage them through a dashboard.&lt;/p&gt;

&lt;p&gt;Redirects are a small piece of code with an outsized effect on lost traffic and lost rankings — get the status code and the placement right, and they quietly do their job for years. If you're planning a larger migration, restructure, or need ongoing WordPress development handled by a team that treats details like this as standard practice, our custom WordPress development team can take it from here.&lt;/p&gt;

&lt;p&gt;Originally published on the &lt;a href="https://webhelpagency.com/blog/redirecting-wordpress-url/" rel="noopener noreferrer"&gt;Web Help Agency blog&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>wordpress</category>
      <category>php</category>
      <category>webdev</category>
      <category>seo</category>
    </item>
  </channel>
</rss>
