Remove Old Permalinks?

后端 未结 3 1556
广开言路
广开言路 2020-12-19 19:59

I have a Wordpress website. I have changed my permalinks several times. All past versions of the permalinks I used are still working. If I type them into the URL bar, I a

3条回答
  •  时光取名叫无心
    2020-12-19 20:28

    As you can see, Wordpress doesn't handle redirections when you change your permalinks structure. There is 2 ways to handle this, through:

    1. The htaccess rewriting rules (manually editing the .htaccess file) depending on your new old/new permalinks structure.
      If .com/lightbulb is the new path and .com/shop/lightbul the old one:
    Options -Indexes
    Options -Multiviews
    Options +FollowSymLinks 
    
      RewriteEngine on
      RedirectMatch 301 /shop/lightbulb(.*) /lightbulb$1
      # or
      # RewriteRule ^shop/lightbulb?(.*) http://www.domain.com/lightbulb$1 [R=301,L]
    
    

    But if you want to redirect old permalink structure .com/shop/ to main domain your .htaccess rules will be:

    Options -Indexes
    Options -Multiviews
    Options +FollowSymLinks 
    
      RewriteEngine on
      RedirectMatch 301 /shop/(.*) /$1
      # or
      # RewriteRule ^shop/?(.*) http://www.domain.com/$1 
    
    

    Permanent redirection is used for best SEO practices, redirecting definitively old permalinks to new ones, avoiding duplicate content, and telling search engines that your old permalinks have been moved definitively to new ones.

    1. Redirection Wordpress free plugins (there is a lot):
      • Redirections plugin is the most popular and offer a easy-to-manage 301 redirections and 404 error tracking. It also offers more advanced tools to help you keep track of loose ends on your site like broken links and orphan pages.
      • Simple 301 redirects plugin is simple and deals with 301 redirect creation for when you’ve permanently moved content from one location to another.
      • Quick Page/Post Redirect plugin easily redirect pages/posts or custom post types to another page/post or external URL by specifying the redirect URL and type (301, 302, 307, meta).
      • Safe Redirect Manager plugin comes with an additional whitelist feature for added security…
      • SEO Redirection Plugin plugin offers support for generating 301, 302, and 307 redirects and also supports 404 error monitoring with easy one-click redirection…

    Converting old path (urls) in database (if they still exist):

    You can use Search and Replace free plugin, to easily find some old related urls or path in your database and bulk replace them by the new ones. This is a very powerful plugin, a little buggy, but working fine when you know it (but make always a backup before).

    A recent reference:
    A Simple Guide to Changing Your Permalinks Without Breaking Your WordPress Website

提交回复
热议问题