Hey Ashley!
I cringe whenever I see my URLs because they include the dates. I had moved from Blogger to WordPress, and I recall having to restructure my permalinks so that the redirection would be flawless. Is there a way to not use that (even with redirection enabled)? I prefer the look that your blog uses with just the post title. Thanks!
Chrys
Hey Chrys! π
Just to backtrack a moment for anyone who doesn’t know: it’s really easy to change your permalinks in WordPress. You simply go to Settings » Permalinks and select a new option. The problem is that if you change your permalinks, your old URLs will break (in most cases.. it does depend on what format you were using. For example, the default one will always work). People will get 404 errors when trying to visit them.
The way around this is to change your permalinks and then redirect the old ones to the new ones. To do this properly, you will have to modify what’s called your .htaccess file. This will be located in the root of your WordPress installation (viewable through FTP access or your host’s “File Manager”). I recommend that you take a backup of your .htaccess file before making any edits so that you can restore it if you need to (incorrectly made edits to that file can result in the “white screen of death”.. or other errors).
Use this permalink helper tool by Yoast to generate the redirect code. Simply fill in the box with your site URL, select your old permalink structure, and press Generate Redirect. The next page will give you a put of code to paste into the top of your .htaccess file. It will look something like this:
RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/([0-9]{2})/(.*)$ http://www.ohchrys.net/$4
This bit of code will redirect all URLs matching the old format to the post title format that I use!
In your case, there will technically be two redirects:
- The redirect from ohchrys.com to ohcrhys.net
- The redirect on ohchrys.net from the old structure to the new structure
It’s confusing, but theoretically it should work! π
Wooooooooooooooooow! So amazing! Thanks so much! Will definitely try this after work. Woo! I thought I’d never know!
Let me know how it goes! π
This is so useful for if I ever move to WordPress. There seems to be so much that you can do on it! :O
Thanks for sharing, Ashley! <33
What if I wanted to redirect to a custom permalink structure like /%category%/%postname%/, is that possible with the permalink helper tool listed above?
Yep, you would just enter your current structure in the “Custom” box.
I’m working on this now and the redirect didn’t work. Any clue as to why? I switched my posts from year/month/date/postname to just /postname. Thank you!
Can you paste exactly what code you put in your .htaccess file?
I put the following at the top of my .htaccess file:
RedirectMatch 301 ^/blog/([0-9]{4})/([0-9]{2})/([0-9]{2})/(.*)$ http://www.meganminns.com/blog/$4
Well at least part of the problem is that your URLs don’t currently have /blog/ in them. For example, here’s a link to one of your blog posts: http://meganminns.com/spunky-sapphire/ notice how there’s no /blog/ in there, so that shouldn’t be in the htaccess rules.
(I don’t know if you USED to have /blog/ in the URL, but if not, you should remove it from the year/month/date/postname rule as well.)
That was it! Thank you for your quick feedback!! π
Fantastic! I’ve been searching for this solution for days. I’m about to migrate from good old Blogger to the big boy WordPress and wanted to keep the nifty permalink structure/customization WP offers ie. http://www.url.com/posttitle but didn’t want broken links to my old pinned and popular posts. I’ll keep you updated on how it goes π
Thanks for this post! BUT I’m scared to make the change (such a nervous nelly). Where exactly should my redirect code go?
This is what it looks like currently :
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
Thanks so much for your response and help!
You can paste it at the top, above #BEGIN WordPress π
You’re awesome to be so quick to respond. I put it there … and then got this message when I tested :
Error code: ERR_TOO_MANY_REDIRECTS
Any ideas?
Did you update your permalink structure within WordPress? And are you sure you pasted in the correct redirect code?
Too many redirects could happen if, for example, you have your permalinks set to be “post name”, but then you tell it to redirect post name to post name… so it’s redirecting on itself.
Ashley – yes! It was that I forgot to change the permalinks in WP. Thanks a bazillion!!
Hi,
I really appreciate you helping everyone. For the same reason as Naomi, mine looks a bit different:
#
#RewriteEngine On
#RewriteBase /
#RewriteRule ^index\.php$ – [L]
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule . /index.php [L]
#
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
Should i pasted it above BEGIN wordpress or above # and with a # in front of it like this: #RedirectMatch 301 ^/([^/]+)/([^/]+)/$ http://www.succesindeliefde.nl/$2 or without?
Hmm strange, there is some kind of code next to the first # that is not visible when i post the comment.
Anything that is after a # sign is NOT doing anything. It’s the equivalent of a “comment” in HTML or CSS. It’s not actually being executed.
You can paste it above # BEGIN WordPress but DO NOT add a # sign in front, or else it wont’ do anything.
Hi,
I appreciate your fast response. Thank you very much.
Best regards,
Jim
Hi,
Something very strange now.
When you visit my homepage and try to click on a post to open it, it does nothing?
Do you know what that is?
Best regards,
Jim
I’ve already got it fixed. So now i won’t lose any of my seo rankings? Cheers, Jim
Provided that the redirect is working (visit an old URL and see if it redirects to the new one) then you will not lose SEO rankings.
Thank you.
Your article was very helpfull.
what the tool can change the permalink from /% year% /% monthnum% /% postname%. html To /% year% /% monthnum% /% post_id% /% postname%. html ? Thanks π
Hi there, I have a problem in my petrmalinks ….as I change them errors on the pages 404… What shall I do?pls help
Great article! I know it’s a while since you published this post, but I’m taking a shot here and leaving a comment anyway.
I want to change the permalink structure for my blog FROM http://creativfriskvard.se/%category%/%postname%/ TO http://creativfriskvard.se/traningsbloggen/%postname%/
In other words, I want to change the %category% value to traningsbloggen (which is the name of my blog page). How would the code I need to add in .htacess look? I’ve only managed to find examples of how to change to http://creativfriskvard.se/%postname%/ and not with the /traningsbloggen/ addition to the URL.
Any help with this is much appreciated!
(And thanks again for a very informative post, made everything with permalinks and .htacess a lot clearer!)
/ Ida
Hi Ashley,
Thanks for a wonderful tutorial. I recently shifted my blog and was looking for a solution for my permalinks and your tutorial really helped me. Thanks a lot π
My pleasure. π
Hi Ashley! I just stumbled across your excellent blog post, while trying to fix permalink on a blog that i recently migrated from blogger to wordpress, too. Just wondering which tool / fix / plugin would you recommend for blogger to wordpress redirection – i assume adding this code into the .htaccess file would only work after having set up redirection… ? Thanks!
Hi Susanna. π Here’s a link to my Blogger to WordPress migration guide: https://www.nosegraze.com/moving-from-blogger-wordpress-walkthrough/
Step 6 covers the redirection process, and in that I explain which plugin I recommend and how to find it. π
great!!! thanks so much ashley, i will read it now. too bad i didn’t have your post at hand when i first started the migration but it will be precious for next time π
My current permalink structure is the wordpress default. I want to change to the post name. When I use the Yoast generator it says this: Your Redirects
You don’t have to do any redirects, WordPress will do it for you.
So I changed the permalink setting on the blog and got this message:
StatPressCN info:Permalink structure has been set to /%postname%/.Updating URLes…
..but it doesn’t appear that anything is happening. No spinning cursor or anything. I’ve tried just letting it run but nothing changes. In the meantime I get a 404 error on all my blog posts. I can change it back to the default setting and it changes back immediately. I’ve let the Updating URLs notice stay up for up to 20 minutes and it never changes. Am I not being patient enough or is it not working?
Ok, when I got tired of having the blog down, I set it back to the default setting and got this message.
StatPressCN info:Permalink structure has been set to default.Updating URLes…
WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘!”’ at line 1]
SELECT id, ptype, pvalue, urlrequested FROM wp_statpress WHERE pvalue !”
The permalink structure is set to default, 0 sets are updated done
Warning: Cannot modify header information – headers already sent by (output started at /home/spiritbl/public_html/wp-content/plugins/statpresscn/statpresscn.php:3189) in /home/spiritbl/public_html/wp-includes/pluggable.php on line 1207
Then I asked it again and it changed immediately back the default permalinks.
Both problems are coming from your “StatPress” plugin.
Seriously? Months. I’ve spent months trying to fix this and all I had to do was delete one plugin? You are my hero!
Hello,
I tried this tool, but the issue is i am not being able to access my wp-admin panel now. I have changed permalink structure from /%category%/%postname%.php to /%postname%/
Now my admin panel isn’t accessible. Any help will be appreciated.
HI Ashley,
I am doing SEO for a client who recently had their website redesigned. Afterwards they took a major hit on the SEO side. So after getting access to their WordPress I discovered that all their URLs are set the default permalink. (which explains the SEO hit)
Therefore, I want to change the permalink structure to postname. And understand that I need to do a 301 redirect from the old links (default permalink) to the new (postname)
However, I do not have access the .htaccess file and have no experience with it.
Do you have any suggestions? What should be my next course of action in changing the permalink without breaking the website. (The clients has a ton of backlinks)
You shouldn’t need to set up redirects if you’re going from the default structure. That structure will always automatically redirect to the permalink setting you choose.
WOWOWOWOWOW, finally, 4 hours im looking for this trick, and i found it here.
i have tried so many plugin and so many methods. and here, its very easy. thanks a lot
god bless u
You’re welcome. π
Hello Ashley,
I am new on blog writing can you please have a video of this article, So, I able to understand better.
Your work is going best for me.
Thanks
Thank you so much for this! It worked like a charm! I had been annoyed by this for a long time and thought there was nothing I could do so I really appreciate it.
I’m clicking on the link to generate redirection code but nothing is opening. I mean page is showing 404 error.
I wqs not aware of this idea. Thanks a lot.