How to Set Up 301 Redirects in WordPress to Optimize SEO and User Experience

What is a 301 redirect in WordPress?

A 301 redirect is an HTTP status code that a web server sends to a browser to indicate that a web page has been permanently moved to a new location. When a user tries to access the old URL, they will be redirected to the new URL by default.This process helps maintain website traffic, link equity, and overall SEO value.

图片[1]-如何在WordPress中设置301重定向以优化SEO和用户体验-光子波动网 | WordPress教程、Elementor教程与故障修复

The benefits of creating a 301 redirect for your WordPress website:

  1. Improving the user experience: When users click on an expired link, they may encounter a "page not found" error. By setting up 301 redirects, users can be automatically redirected to the correct page so that their browsing experience is not interrupted by an incorrect link.
  2. Protecting SEO results: Search engines consider 301 redirects to be permanent changes and will pass the search rankings of the old page to the new page. If you do not set up permanent redirects, your website may lose its ranking and authority in the search engines.
  3. Keeping links active: If you reorganize your website or change the address of a web page, a 301 redirect ensures that any old links are directed to the new page. This prevents users from getting frustrated because they can't find the content and maintains the professional image of the site.
  4. Reducing content duplication: If multiple URLs display the same content, search engines may have difficulty determining which is the most authoritative version. By setting up 301 redirects, you can direct users from duplicate pages to the main page and improve the search engine visibility of your website content.
  5. Improvements. Over time, blog posts may become outdated, inaccurate, or no longer meet your current goals. With 301 redirects, it is possible to improve existing WordPress content by replacing underperforming posts with more recent ones.
图片[2]-如何在WordPress中设置301重定向以优化SEO和用户体验-光子波动网 | WordPress教程、Elementor教程与故障修复

5 Ways to Set Up a 301 Redirect in WordPress

To create redirects automatically, use the 301 Redirect WordPress plugin. For skilled users, 301 redirects can also be set up by manually editing a site's .htaccess file or creating a custom PHP script.

Setting up 301 redirects in WordPress using the AIOSEO plugin:

1. Navigate to the WordPress dashboard and find "plug-in (software component)"->"Add New Plugin", search for "All in One SEO"Waiting for results.

图片[3]-如何在WordPress中设置301重定向以优化SEO和用户体验-光子波动网 | WordPress教程、Elementor教程与故障修复

2. SelectionInstallationand then clickactivateThe

3,Open the plugin settings: After activation, find the "All-in-one SEO" (or AIOSEO) settings option.

4. FindRedirection Manager(Redirects): in the AIOSEO settings, scroll down until you see "Redirection Manager"This option is clicked to enter the Manage Redirects screen.

图片[4]-如何在WordPress中设置301重定向以优化SEO和用户体验-光子波动网 | WordPress教程、Elementor教程与故障修复

It's time to start creating 301 redirects and easily manage changes to your website URLs, while enjoying other SEO-boosting features from AIOSEO! This plugin redirection is only available for licensed professional users.

How to set up 301 redirects using the 301 Redirects plugin

图片[5]-如何在WordPress中设置301重定向以优化SEO和用户体验-光子波动网 | WordPress教程、Elementor教程与故障修复

301 Redirects is another WP plugin that correctly redirects users from the source URL to a new destination. In addition to creating permanent 301 redirects, its free version also allows you to set up temporary 302 and 307 redirects:

  1. Log in to the WordPress dashboard and install301 RedirectsPlug-ins.
  2. installation andactivateAfter the plugin, navigate to the"Settings"and find301 RedirectThe
  3. switch toRedirection rules and select redirectionOne of the types -301, 302or 307 The
  4. exist"Redirected from"Enter your existing page or post URL in the section.
  5. exist"Redirect to"Next, set the drop-down menu to"Customization"and enter a new link.
  6. click (using a mouse or other pointing device)"Save."Button.
图片[6]-如何在WordPress中设置301重定向以优化SEO和用户体验-光子波动网 | WordPress教程、Elementor教程与故障修复

How to set 301 redirect manually by editing .htaccess file

Manually editing the .htaccess file is another viable option. Follow the steps below to locate the .htaccess file in the root folder of your site and create a 301 redirect:

1. Use an FTP client or file manager to access the files on your site. Navigate to"Documentation" → "File Manager"and access the site's files.

2. Openpublic_htmlfolder and double-click the.htaccessDocumentation.

3,In the RewriteEngine onBelow the line, add the following code snippet to set up a 301 redirect:

Redirect 301 /old-url/ https://www.example.com/new-url/

4. Replace /old-url/ with the source URL and https://www.example.com/new-url/ with the target URL.

5. Then save the .htaccess file.

图片[7]-如何在WordPress中设置301重定向以优化SEO和用户体验-光子波动网 | WordPress教程、Elementor教程与故障修复

It is also possible to use .htaccess redirects to move old sites to new domains:

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

commander-in-chief (military)olddomain.comrespond in singingnewdomain.comReplace it with the domain name of your website.

图片[8]-如何在WordPress中设置301重定向以优化SEO和用户体验-光子波动网 | WordPress教程、Elementor教程与故障修复

How to set up a 301 redirect using a PHP script

Advanced users can also create PHP scripts to set up 301 redirects in WordPress. This method is useful for managing multiple redirects.

pass (a bill or inspection etc) filefile managerAccess your WordPress files. Follow the steps below:

1. Openpublic_htmlFolder.

2. On the sidebar, click the"New document"and named it " redirects.php"The

3. Once created, a new PHP file will automatically open with the following code added:

<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: https://www.example.com/new-url/");
exit();
?>

4. Willhttps://www.example.com/new-url/Replace it with the new URL you want to redirect to. you can add more than one of this block for different redirects.

5. Click Save PHP File.

图片[9]-如何在WordPress中设置301重定向以优化SEO和用户体验-光子波动网 | WordPress教程、Elementor教程与故障修复

To test if the 301 redirect works, open your browser and enter the address of the PHP script - it should look like this:

https://www.yourwebsite.com/redirects.php.

What are other types of redirection codes?

The 301 status code is not the only option available when creating redirects. There are several different status codes that can be used, each with their own specific purpose. Below are some common types of redirects, along with their respective characteristics and scenarios:

  • 301 redirect (permanent redirect) This redirect is used to tell browsers and search engines that a page has permanently moved to a new URL. If you are sure that the content or address of a page has permanently changed, you should use a 301 redirect. It helps to maintain the SEO value of your website, such as link weight and rankings, while ensuring that users have smooth access to the new page.
  • 302 Redirection (temporary redirection) If you are only moving a page temporarily, such as for site maintenance or testing, you should use a 302 redirect. This tells the browser that the change is only temporary and that the original URL will be restored sometime in the future.
  • 303 Redirect (see other) A 303 redirect is often used after a form has been submitted to direct the browser to jump from the page where the form was submitted to a new page. This ensures that when the user refreshes the submission page, the form is not submitted repeatedly.
  • 307 Redirect (temporary redirect, HTTP 1.1) Similar to a 302 redirect, a 307 ensures that the method and identity remain the same and is used for temporary page moves.

When to use a 301 redirect

图片[10]-如何在WordPress中设置301重定向以优化SEO和用户体验-光子波动网 | WordPress教程、Elementor教程与故障修复

Implementing 301 redirects ensures a seamless user experience and maintains your website's SEO ranking. Here are some scenarios where 301 redirects are highly recommended:

  • standardization.. Having multiple pages with similar content can have a negative impact on search engine optimization. Use 301 redirects to combine the ranking potential of these versions into a single URL. Common examples include HTTP to HTTPS and non-www to www redirects.
  • Page or post deletion. If you want to remove a high-traffic page or post from your website, redirect it to a new location first. This method will prevent users from encountering404 Not FoundError.
  • Website ConversionWhen you make major changes to your website. When major changes are made to a website, including the creation of new categories or changes to the URL structure.
  • domain migration. When moving your website to a brand new domain, it helps you transfer existing traffic and SEO authority from your current domain to the new URL.
  • URL being updated. After you update the URL to optimize keywords or improve the readability of the URL, this not only prevents you from generating invalid links, but also maintains the authority of your site's content and search engine rankings.
  • Changes to the permalink structure. If you change the permalink structure of a post or page, the old link will become invalid. To avoid breaking external links and bookmarks, set up a 301 redirect from the old URL to the new URL.

reach a verdict

It's critical to use 301 redirects when you migrate to a new domain, reorganize your site structure, or update your URLs. This helps to maintain the user's access experience and preserve your SEO rankings.

  • Use redirection plugins like AIOSEO and 301 Redirects.
  • Manually edit the site's .htaccess file.
  • Create custom PHP scripts.

Contact Us
Can't read the tutorial? Contact us for a free answer! Free help for personal, small business sites!
客服微信
Customer Service
Tel: 020-2206-9892
QQ咨询:1025174874
(iii) E-mail: [email protected]
Working hours: Monday to Friday, 9:30-18:30, holidays off
© Reprint statement
本文作者:红牛独立站
THE END
If you like it, support it.
kudos0 share (joys, benefits, privileges etc) with others
commentaries sofa-buying

Please log in to post a comment

    No comments