As I mentioned yesterday I switched this blog over from michele.me to michele.blog. And a BIG thanks is owed to Don and Paolo from the .blog team for helping me get that domain in the first place!
The michele.me domain will be used for “other things” in the future, so I am splitting the blog away from the rest of the site.
As part of the switch I’ve also changed the WordPress permalink structure over to the shorter or more direct /%postname%/ using Yoast’s handy little tool to generate the necessary rule.
In order to do that “sanely”, while also trying not to lose any web traffic I’ve got two sets of redirects setup:
- Over on the michele.me server there’s a mod_rewrite rule in Apache that is meant to catch any traffic destined for michele.me/blog and send it to michele.blog, while preserving the requested URL. eg. if the requested URL was http://www.michele.me/blog/archives/2016/12/working-preparing-new-house/ then it should pick up on the bit after /blog/ and send it over to the other server so that you land on https://michele.blog/working-preparing-new-house/
- On the michele.blog server there’s a mod_rewrite rule in the .htaccess that will map the old permalinks to the new and shorter one (the example above shows how stupidly long the paths were previously). It’ll transform the old (and super long) URL to the shorter permalink structure.
Everything is *almost* working, but there are a few stupid problems that I can’t seem to fix, though I know they should be fixable via mod_rewrite.
At the moment *any* traffic hitting http://www.michele.me/blog ie. the former “root” or “home” of this blog is being sent to the wrong place. Instead of it going to https://michele.blog it’s ending up at https://michele.blog/blog-award-time/
The mod_rewrite rule in Apache is:
RewriteRule ^/blog/ https://michele.blog%{REQUEST_URI}
So while it’ll pick up every other URL that was under michele.me/blog it’s not handling the “root” link properly at all.
On this server there’s a mod_rewrite rule that is handling the mapping to specific posts, pages etc.,:
RedirectMatch 301 ^/blog/archives/([0-9]{4})/([0-9]{2})/([^/]+)/$ https://michele.blog/$3
I’m not sure which of the two rewrite rules is missing something, but I suspect it’s the first one.
So if there are any Apache mod_rewrite gurus out there who have any idea on how to fix this before I lose my mind I’d love to hear from you!
dr1ss says
mod_rewrite can be fun at times 🙂
After a quick check, your issue doesn’t concern your old domain. The redirection is fine, what you should investigate is why https://michele.blog/blog redirects to https://michele.blog/blog-award-time/ because that’s where people from your old domain get redirected to.
As a “quick and dirty” fix in mean time what you can do is add this line on your old htaccess :
RewriteRule ^/blog/?$ https://michele.blog [L]
just before the line :
RewriteRule ^/blog/ https://michele.blog%{REQUEST_URI}
this should redirect the old homepage straight to to your new address.
Michele Neylon says
Thanks, but when I try that I can’t get michele.me/blog to load at all 🙁
dr1ss says
Would be great if you could share the whole htaccess to better identify the issue
Michele Neylon says
@dr1ss – Stephen managed to fix it – so the new rule is:
RewriteRule ^/blog/?$ https://michele.blog [R=301,L]
RewriteRule ^/blog/ https://michele.blog%{REQUEST_URI} [R=301,L]
Thanks – you pointed him in the right direction and it all seems to be working properly now 🙂
Michele
dr1ss says
Yeah the second rule needed the [L] probably because u had other rules after (that why I asked to see the htaccess hehe)
Glad everything is working as you want