A Complete Guide to WordPress Permalinks and 301 redirects

A Blogger's Complete Guide WordPress Permalinks and 301 Redirects

Everything you need to know about changing WordPress Permalinks and 301 redirects

In this post, we’ll walk through changing permalink settings on a new WordPress Installation and how to do 301 redirects when changing permalink settings on an established site.

Changing Permalink Settings on a New WordPress Installation

One of the first things to do, when you log in to your newly installed WordPress dashboard is to adjust the permalink settings that will set the URL structure for the site. You can do this by going to the Settings → Permalinks panel.

The default permalink setting for WordPress creates ugly URLs/?page_id=23 using the post id number. Changing to one of the date structures isn’t much better. The best option from an SEO perspective is to choose postname to put the title of your post in the URL.

Customize each Page/Post Permalink

Once you’ve saved the permalink settings you can see this in action as you customize the permalinks for each page and customize the permalink for every post you publish. Go to Posts → Add New… now type a title for your post. Right below the post title you’ll see the Post Permalink. The full title of the post will now be in the URL. This probably means that some of your posts will have long titles.

Here’s the URL for this post dandelionwebde.wpengine.com/changing-your-…ess-permalinks/. WordPress adds the post title. As the title was too long for the permalink “…” was inserted. I’ve edited the permalink to make it pretty dandelionwebde.wpengine.com/changing-permalinks/.

When you edit page & post permalinks keep them short, use keywords, stick to lowercase and use dashes to separate the keywords, not spaces. Search engines recognize separators.

How to change WordPress Permalinks & create 301 redirects without breaking your site!Click To Tweet

Should I Change Permalinks on an established site?

I’m often asked about changing permalinks on an existing site. The worry is that changing the permalinks will create broken links impacting the traffic that you already have, sending visitors to a 404 error page. The answer is YES I would recommend changing your permalink structure even if you have an established site BUT make sure you read on…

If you are running WordPress with the default plain structure ?p=123 structure you don’t have to worry. Go ahead and change your permalinks. WordPress will automatically forward to the new structure.

301 Redirect to Your New Permalink structure

If you’re using one of the date or the numeric permalink structure options you’ll need to redirect your old permalinks to your new ones.

Go to the Yoast Plugin and find “Edit files”. This will open your .htaccess file for editing. Yoast is making this so easy for you!

If your structure is

  • Day and Name /%year%/%monthnum%/%day%/%postname%/ your redirect should be RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/([0-9]{2})/(.*)$ http://yourdomain.com/$4
  • Month and Name /%year%/%monthnum%/%postname%/ your redirect should be RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/(.*)$ http://yourdomain.com/$3
  • Numeric /archives/%post_id% your redirect should be
    RedirectMatch 301 ^/archives/(d+)$ http://yourdomain.com/?p=$1
  • Postname and you want to switch to a custom structure of /%category%/%postname%/ there is no way to redirect with .htaccess but you can accomplish this with the Permalinks to Category/Permalinks plugin

You can use this handy Permalink Helper tool from Yoast

301 redirects for individual posts/pages/category or tag archives in the .htaccess file

If you delete a page, a post, a category or tag you could be creating broken links — you’ll need to create individual redirects.

If you want to use a plugin to create 301 redirects, I recommend the WordPress SEO Premium plugin which includes a redirect manager. But you don’t need to use a plugin, you can add redirects to your .htaccess file.

In the Yoast SEO → Tools → File editor (or if you prefer to access your site by FTP. You may need to turn on hidden files to find the .htaccess file). Then add the following to the bottom of the .htaccess file. Put each new redirect on a new line.

redirect 301 /old/old.htm https://yoursite.com/new/
  • replace /old/old.htm with your old URL. Do not include http:// or https:// or www. Include the full path from the top level of your site to the page
  • replace https://yoursite.com/new/ with the full path including https:// or https:// or www – make sure you match the structure used on your site’s Settings → General page. Include a trailing slash (/) at the end of your URL

It should work like a charm.

NOTE: If your site is hosted by WPEngine you need to contact support. They have a hosting control for redirect management that doesn’t use the .htaccess file.

80 thoughts on “A Complete Guide to WordPress Permalinks and 301 redirects


  1. This is so informative, as one of my clients has the date and post name in her permalinks, but would like to drop the dates, and I wasn’t sure how that would affect things. Thanks!


      1. Hi Ruth,
        I am very new to WordPress (like today) and have realized that the permalink I have created is wrong and I need to change it. When I go to settings there is no permalink option in the drop down menu. What do I do?


        1. Hi Elaine,

          Welcome to WordPress!
          First of all, are you on a WordPress.com site or a self-hosted WordPress.org website? This assumes a self-hosted site.
          Are you logged in as an administrator? If you aren’t a full administrator you won’t see all the options that are available to an administrator.
          Are you choosing Settings -> Permalinks and not settings from a plugin or theme?


          1. Hi Ruth

            I have an established website and have the word “Category” in the permalink structure and would basically like to either rename it or remove it without creating hundreds of 404s any suggestion?


  2. Hey Ruth,
    Very, very informative guide here. I have a client who has changed their permalink structure twice.

    The first iteration was site.com/year/mo/day/post-name
    Next it was site.com/category/post-name
    Now it’s site.com/post-name and that is where they intend to keep it. They have about 9000 crawl errors stemming from these changes. I’d like to implement the rules here, but need some guidance on how.

    I see the year/month/day part is addressed: RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/([0-9]{2})/(.*)$ http://yourdomain.com/$4

    What I’m not sure about is migrating /category/post-name to the latest structure, which is just /post-name. Is there a way to do that?


  3. Hi Ruth,
    I have a quick question on Permalinks change:

    I have an established site and, as I’m still new to learning WordPress, I have been using the ‘Default’ setting on my Permalink Settings page. If I change to ‘Post Name’, will it go back and change all my old posts and pages? Or will it only change the new ones (posts & pages) I create?

    I tried to Download “permalinks migration plugin” as was recommended by others when you have an established site to be sure all old ones get redirected OK but WP is showing this plugin is not found. My site is http://www.travelingroundtheworld.com

    Thanks

    Rory


    1. Hi Rory,
      Changing your permalink structure will change it on the old posts & pages as well as the new ones. Last time I checked the permalinks migration plugins were all broken but you don’t need one. You’re changing from the default ?p=123 structure so you don’t have to worry WordPress will automatically forward to the new structure.

      Your permalinks will take the names of your posts with dashes for spaces. Some of these may be too long so you can go in and manually edit each post.

      You can also remove your uncategorized category. Just set a different one to be the default post category in settings -> writing. Once that is changed you can delete uncategorized.


  4. I am working on http://www.classifiedsduniya.com. and this website has 19000 classifieds listings. As per SEO perspective i want to change my permalink structure for all posts like that (/%category%/%postname%-%post_id%/) or (/%postname%-%post_id%/). Please suggest me that how can i change my permalink and what should be changes in .htaccess file to change my older permalinks..

    Please share your suggestions..


    1. Hi Sunil,

      Sorry for the long delay responding I missed seeing your comment. You don’t need to add %post_id%/.

      Changes to .htaccess would depend on what your old structure is. Please tell let me know what the old permalink structure is.


  5. Hello, thanks for this tutorial. I was wondering if there is a way to change permalink without affecting ranking? Is there any wordpress plugin you recommend?

    Also i saw some site url showing this on search engine. (even your too) something like this > home >category >tag >post title

    the important feature is the ‘>’ sign, how do one achieve it?
    Thanks.


    1. 301 redirects will ensure that you don’t negatively impact on your ranking. Just read the second half of this post again.

      The » symbol that I often use for a breadcrumb trail can be achieved by holding down the alt key and using the number pad on your keyboard to type 175.


    1. Navid,
      Try the Yoast permalink tool. Put in your old structure and it will give you the code to add to the htaccess file.


  6. Hi Ruth,
    Thanks to you for your great job. I learn so much from this site. As a web designer I can say, anyone can benefited from your site. But I am wondering if any of these are compatible with Joomla. The blog program especially is attractive to me.


    1. The information given here about how to do a 301 redirect in .htaccess is the same on any website but the post is WordPress specific.


  7. Thank you so much for this article Ruth. I have had the default permalinks on the blog portion of my site since it was first created in ’08. For more than 3 years now I have wanted to switch to a more descriptive form of permalink, but was afraid to for fear of what it would do to all the search engine and other links that are coming into my site. I had looked at so many plugins over the years, and read so many articles, but until yesterday, had no idea that all I need to do is just click on a radio button and save my choice.

    This article has saved me further hours of frustration and stress, since at my hosting company’s request I had to install Super Cache–something I of course couldn’t utilize to its best capacity with the WP default permalinks.

    Your blog is a very interesting & easy to understand read, and one I will recommend to my friends who work in the WP environment. Thanks for your writing efforts Ruth! You really helped me, as I’m sure you’ve helped others immensely. Glad to have found your site…helen


  8. Fantastic post, Ruth! It can be exceptionally confusing for WordPress users — both new and experienced — when it comes to changing your permalink structure.

    I have a client who changed her structure from /%category%/%postname%/ to /%postname%/ successfully. Site redirected links fine. Google reindexed and redirects work fine there as well. Problem is, she promptly fell off Google search results. I read that this can happen, but it’s been a couple of months since the switch and the situation is yet to improve.

    Exact match searches for blog post titles return results from Facebook and other places the content has been shared, but not for her own site where the content was first posted. The only was to get a blog post to appear is with an exact match search for the title combined with a site: search for her site.

    Have you ever heard of this happening before? Or do you know a solution?

    Thanks for the tips anyway! I’ll be sure to bookmark the page to help simplify the whole process next time around. 🙂


    1. Hi Anna,

      I’m glad you found the post helpful. Strange that her site ranking has been impacted. With 301 redirects this really shouldn’t be an issue. Are there possibly other SEO practices that have affected her site ranking?


      1. It is strange, I agree, Ruth. But she wasn’t participating in any type of SEO when we made the switch, and it’s only in Google; other search engines she ranks just fine. I even submitted a reconsideration request to Google on her behalf and they informed me that they have no penalties against the site. It’s just so weird because a site: search brings everything up, but you just can’t find it otherwise, and no one seems to know what’s happened.

        I only thought it may have something to do with the URL structure change as not much else happened.

        Guess we’ll have to focus on marketing a bit more and hope our efforts pay off or the situation fixes itself! Thanks for your reply! 🙂


        1. Anna K, Has she checked to be sure that her pages/posts are still being “indexed” Sometimes with the Yoast plugin even I have noticed it switching my settings to “noindex” Or perhaps she could have a bad plugin? I would recommend to go through backup the entire site and database, disable plugins, update to the latest version of WordPress, update all plugins, and then enable one plugin at a time, while deleting any unnecessary ones. You’d also be surprised by how much just an outdated plugin can affect a site.


  9. Ruth, thank you so much for this article. It is not only very informative, but also very well written and easy to understand. I am in search of an answer to one small question I cannot seem to find anywhere, perhaps you can help…

    If I were to change my permalinks to category/postname then later on, if I change the name of a category, would it break the those links? Would the link or slug stay the same with just a different title?

    Also the same scenerio for the simply/postname/ option, If I were to later go back and change the title of one of my posts, would the permalink change as well and leave me with broken links?


    1. Hi Nikki,

      Yes you can change the title of a post… just confirm that the permalink doesn’t change – it shouldn’t.

      I would do a 301 redirect if I change a category. Open the .htaccess file in the Yoast plugin (under edit files) and add the following

      redirect 301 /oldcategory/ http:// mysite .ca/newcategory/ (no spaces I just didn’t want to create a link)


  10. I also follow this step and it works well. But my issue is little bit different.
    My permalink structure was /%year%/%monthnum%/%postname%/ before 21st January, 2013. I redirected Attachment url to parent post url through Yoast’s seo plugin and it works.
    But after 21st January, 2013, I change my permalink structure. /%category%/%postname%/%post_id%/
    and I redirect my old permalink structure to new permalink structure. (with Simple 301 Redirects plugin)

    I uncheck Attachment url to parent post url in Yoast’s seo plugin and then once again check the box of Attachment url to parent post url. So that refresh Yoast’s seo plugin and it works normally. But it works only with new permalink structure (/%category%/%postname%/%post_id%/), not working with the old permalink structure(/%year%/%monthnum%/%postname%/). And therefore it is result in so many 404 errors.

    Attachment url to parent post url is working only for those post which I published after 21st January, 2013. Before this date I published almost 594 post and for all those post, Attachment url to parent post url doesn’t work. One solution is there with Simple 301 Redirects and it is that I have to redirect my each image of those 594 posts to their parent post url. You can understand, I have to redirect almost 3000 + images one by one.

    I have trying lot to find out solution since last 20 days. But I have no solution.


  11. Hello,

    My site was running with permalink structure /%category%/%year%/%monthnum%/%day%/%postname%/ earlier. Now I changed the structure to /%category%/%postname%/ but the Old Url’s are not properly redirecting back to new one. I tried the redirect rule RedirectMatch 301 ^/blog/([^/]+)/([0-9]{4})/([0-9]{2})/([0-9]{2})/([^/]+)/$ http://www.mysite.com/blog/$5.

    Can any one please help in writing a proper redirect rule.

    Thanks


    1. Samata – the Yoast permalink helper suggests
      RedirectMatch 301 ^/([^/]+)/([0-9]{4})/([0-9]{2})/([0-9]{2})/([^/]+)/$ http://example.com/$5

      remove the blog/ from the beginning of your redirect and see if that does it.


  12. I have been wanting to change my permalinks for a while but didn’t know how to do it without breaking everything. I just did it following these instructions, and it worked beautifully! Thank you so much!


  13. Hi Ruth,

    Great article, however, I may have read it a little too late myself! Hopefully you can help.

    I changed my sites permalink structure from Year/Month/Day to Post Name after a few months of it being live and I now have about 100 crawl errors for the posts. Google is still looking for the original structure and as a result, is throwing back these errors.

    Will adding a redirect in the .htaccess resolve the issue and if so, how should it be implemented?

    Thanks!

    Damien


    1. Yes you can still add the redirect in the .htaccess. When your done, login to your webmaster tools and resubmit your sitemap.xml file.


        1. Steve,

          Don’t put your url in the custom permalink structure just the /%postname%/

          If that is right and you still have the issue it may be that WordPress is unable to write to your .htaccess file. Can you check if it is writable? If you aren’t comfortable with FTP you can contact your host and ask them to help you.


          1. Hi Ruth

            Contents of my .htaccess below

            RedirectMatch permanent ^/$ http://www.tivfoto.co.uk/wordpress

            # BEGIN WordPress
            RewriteEngine On
            RewriteBase /
            RewriteRule ^index\.php$ – [L]
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule . /index.php [L]
            # END WordPress


          2. Ah you’re running WordPress in a subdirectory “/wordpress” Try this for your permalink /wordpress/%postname%/


  14. Thanks Ruth it worked to some extent, this is the address bar, it now shows the page title ( which is how I want it to look) http://www.tivfoto.co.uk/wordpress/taking-shots-of-bands/

    But sadly, the content of each post is blank , returning an error 404

    I’ve left it as I’ve chabged it with the new permalink structure to custom with the settings you advised.

    Need to find out why its not showing the correct content. On the homepage after changing permalinks, the title in the tab in explorer still showed ‘Nothing found for WordPress’ although the content for the homepage (my posts) is now showing in full whereas it didn’t before, which is also good

    Hmmm


  15. Hi Ruth

    I don’t have a reason for running the install in a subdirectory other than I bought the ‘WordPress add on’ as part of my hosting, they must have automated the install into a subdirectory so that I could also have other ‘add on’s’ on my site as well. I will have a think about what you have said and thanks you very much for helping me out with this.


  16. thats a great article, i also wanted to remove dated parmalink to post name but afraid of 404 errors, but did it successfully with your provided link “WordPress Permalink Generator by Yoast”, its relly great. thanks again.


  17. I changed my old wp and update this with a new theme but have issues with my new urls redirects, searching a plugin to make 301 correctly and tried some of this but still searching the best option for me.
    Could you recommended to me the best wp plugin to make my 301 redirects?

    Thanks.


  18. THANK YOU, THANK YOU, THANK YOU!!

    After going in full-on panic-mode, I can now sleep in peace that my site is okay! 😉

    Super easy instructions, re-direct site referenced above worked perfectly, and my site didn’t break when I, not html-savvy, pasted into the file. Phew!


  19. I am using custom permalink structure with /%year%/%monthnum%/%postname%.html I just want to change it to /%author%/%postname”.html how can I redirect the old to new? please help.


    1. Faheem,

      Why do you want .html appended to the end? I don’t recommend it.

      If you use this (replace example.com with your url) it will redirect to the standard postname without the .html. This is what I would recommend using.
      RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/([^/]+).html$ http://example.com/$3

      I’ve never used /%author%/ but it is a valid WordPress structure tag so it should work but I don’t know the syntax sorry.


  20. Thanks for your response.

    I have added:

    RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/([^/]+).html$ http://en.pcfavour.info/$3

    at the start of .htaccess file. Then I have changed custom structure to Month and name. But it is creating Not found error for old URLs with .html.. What to do?


  21. I have this site set up using the p=123 set up and when I simply change it to /%postname%/ I get the 404 Not Found Error. Please help. I’ve tried 301 redirect plugin and the yoast generator tells me the same thing you have. But all my links are broken.


    1. You don’t need a redirect plugin or any htaccess code for this. from the default ?p=123 structure WordPress will automatically forward to the new structure. If you are getting a 404 try clearing your browser cache, especially if you are running a caching plugin.


      1. Tried changing it and then using a different browser with a completely reset browsing history and cache and I get the 404 error every time.
        Super stuck on this one.


  22. Hi,

    I have /index.php/%post_id%/%postname%/

    which I want to do a ‘global’ redirect to

    /index.php/%category%/%post_id%/%postname%/

    is this possible?


    1. Hi Neil,

      First of all you don’t want index.php in the permalink. Secondly, I don’t believe you can use both %post_id% and %postname% I think it’s one or the other but I’m not sure. Using /%category%/%postname%/ will make your urls quite long. I don’t see why you would want the post id in there as well.


      1. Thanks Ruth,

        You can use both %post_id% and %postname% as I use it now… the ID is used as there are many news items and some could potentially have the same name. Maybe I just need to leave the category out and leave as is.


        1. WordPress won’t allow two posts to have the identical permalink. It will add a number automatically if the permalink is already in use.


          1. I have rmeoved the index.php – not sure how/when that sneaked in… Thanks 🙂


  23. Hello,

    I displaced my website “http://www.mywebsite.com” to “http://www.mywebsite.com/blog” and after a few months, I displaced posts as before and I deleted all content from /blog.

    The problem is that Google still reference the same article as duplicate content, I do the redirection links manually, but there are more than 9000 links deemed not found, I will not finish!

    I tried to solve this problem with the tool of Yoast “https://yoast.com/wp-content/permalink-helper.php,” but either it doesn’t work for me, or that I haven’t understand how.

    Do you have a solution please?

    Thank you.


  24. I’ve made a few posts with the default setting. When I switch to Post Name, I get page not found errors when I try to click on the post links. I am using Windows 2012 server. Do I need to change some other setting to activate URL rewriting?


      1. Thanks for responding. I didn’t, but I don’t see how it will help. When I switch modes, new links are created, so there shouldn’t be anything in the cache. The problem I am experiencing is that the page is not found.
        I am changing from website?p=123 to website/communication. When I browse to the website/communication, I get a not found error.


  25. Thanks so much for this post. Very simple and to the point. I’ve been contemplating making a change from year-month-day-postname to just postname for quite some time and your instructions made it sound like it wouldn’t take much time or effort.

    Literally took me less than 60 seconds with the tip about Yoast’s file editor to add the htaccess code. Perfect!

    Thanks a ton,

    Kyle


  26. Ruth; when doing a 301 redirect for one page in my .htaccess file through SEO->tools->file editor->.htacces, do I also change the permalink on the actual post page?


    1. Yes Irene if you want the page to have a different url then you change the permalink. What you are doing in the .htaccess file is just telling search engines where to find it. It’s like giving the post office a change of address card.

      OH but wait. Your sites are with WPEngine. On WPEngine 301 redirects need to be done in the User Portal. Follow these instructions http://wpengine.com/support/redirect/.


  27. So, I already did it myself instead of going through WPEngine. Is that a problem? Do I need to undo and then do it the WPEngine route?


  28. Is there anyway to do this without losing the number of pins it shows that have been repinned from a post?


    1. I expect that you’ll lose social sharing numbers on your post, I don’t know of any way to carry those over. If anyone has pinned your image it will redirect them to the new url but just so you know Pinterest is suspicious of redirects and may flag the link with a warning – especially if the domain name is changing.


  29. In my experience, WordPress automatically 301 redirects /old-slug/ to /new-slug/ whenever a change is made to the slug/permalink.

    I find it confusing that you are recommending a change to htaccess when it works in WordPress by default?


  30. I have a question, and you may have answered it in this article, but I want to be sure. I have a 2.8 year old WordPress site, which I have been using this url layout “http://www.woodlandsjournal.com/2015/10/05/the-cynthia-woods-mitchell-pavilion-ranked-number-one-amphitheater-in-the-world/” which includes the date, which I want to drop. I have also shared every post since the beginning of my publication to our FaceBook page. The links showing up on the FaceBook page currently show the date in the url link. Once I change the format, will the 301 redirect also redirect traffic from the links people click on from FaceBook, since the url structure of the site will have changed to not include the date in post url any more? Any advice on this, or the way to do it is appreciated. I don’t want to lose traffic from our FaceBook page which people may click on to navigate to the site.

    Thank you,

    Jason Franklin


      1. Ok, that’s good to know that the 301 redirect will take care of old url’s from Facebook page to. How long does it typically take to start redirecting? I played with this a few days ago, and added a 301 redirect in my site. I looked about 10 minutes later, and the old url links were still directing to a page not found. I deleted cache as well. Is this something that can take up to 24 hours?

        Thank you,

        Jason Franklin


  31. Hi Ruth,
    is it possible, that chaning the permalinks can break other paths of the website? Like image or javascript paths? If so, how can I change that?

    Thanks in advance 🙂
    Ann-Kathrin


  32. Right now I have 31 post and they are all permalinks. Can I just change one post to a full descriptive permalink for now and change the others later? I’m afraid if I change the one it will make me change all of them right now when I remove the use of permalinks all together.


    1. Steven,

      If you change the permalink structure in general settings it will change for all pages/posts site-wide. WordPress will automatically generate the permalink based on the page title. You would want to do this when you have time to go through the site and customize them all.


      1. You are spot on! You confirmed what I was afraid i would have to do. I am making a list with all the old urls and also the new urls so i can go through and change them all at once. There are at least 80 pages so its going to be a lot of work. Thank you so much for your help! You just recieved a backlink from a strong website if you want it! I put the url in the website slot if you have ahrefs.


        1. The URLs will automatically all change. You won’t have to change them unless you want to customize them. For instance /?page_id=35 will automatically change to /about which is fine but ?page_id=186 will become 21-day-fix21-day-fix-extreme if you want to shorten that you would have to do so manually.

          You are using the Plain structure so the redirects will automatically happen so you really don’t have to worry. The only issue is if you want to customize URLs to make them shorter – that has to be done manually and immediately after the switch before Google picks up the new links.

Leave a Reply

Your email address will not be published. Required fields are marked *