• Skip to main content
  • Skip to primary sidebar
  • Skip to footer
Michele Neylon :: Pensieri

Michele Neylon :: Pensieri

Technology, Marketing, Domains, Thoughts

Mod_Rewrite Help Needed!!

January 12, 2017 by Michele Neylon 5 Comments

frustrated and exhausted man

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:

  1. 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/
  2. 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!

 

Related Posts:

  • Instafest-mneylon-2023
    Another Year of Listening to Music Visualised (sort of)
  • computer-code-screens
    Dodgy WordPress Developer Tactics
  • 292580518_118073084270186_721063704789268417_n
    Keeping the Greenhouse Under Control is an Uphill Struggle!
  • rhubarb-strawberry-crumble
    Enjoying the Harvest From my Garden Already
  • 461385780_18459713311054922_6444784405823228692_n
    Some People ....
  • Video thumbnail for youtube video 0c4v7fp5gc8
    Sinéad O'Connor Troy

Filed Under: apache, wordpress Tagged With: google, php, Uniform Resource Locator, wordpress

Michele is founder and CEO of Irish hosting provider and domain name registrar Blacknight. Read More…

Reader Interactions

Comments

  1. dr1ss says

    January 13, 2017 at 9:25 am

    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.

  2. Michele Neylon says

    January 13, 2017 at 10:54 am

    Thanks, but when I try that I can’t get michele.me/blog to load at all 🙁

  3. dr1ss says

    January 13, 2017 at 10:59 am

    Would be great if you could share the whole htaccess to better identify the issue

  4. Michele Neylon says

    January 13, 2017 at 11:09 am

    @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

  5. dr1ss says

    January 13, 2017 at 11:11 am

    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

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

dotblog founder

Mastodon

Archives

  • Bluesky
  • Instagram
  • Threads
  • Twitter

Pages

  • About Me
  • About This Site
  • Archives
  • Comments Policy
  • Contact Me
  • Newsletter
  • Privacy

Blogroll

  • My Mastodon
  • Gianni Ponzi
  • Blacknight Blog
  • Technology.ie Podcast
  • Gordon Hudson

Stalking Links

Subscribe to Michele Neylon :: Pensieri

Blogroll

  • Blacknight Blog
  • Damien Mulley
  • Gianni Ponzi
  • Gordon Hudson
  • Grandad
  • My Mastodon
  • Paul Savage – BlackDog SEO
  • Stewart Curry
  • Technology.ie Podcast
  • Tom Doyle

Sites

  • Business Travel Tips
  • Discount Coupon Codes
  • Domain News
  • Fat.ie – my diet blog
  • Film Posters
  • Film Reviews
  • Films
  • Free Desktop Wallpapers
  • Irish Blogger Discussion Forum
  • Irish Stamps
  • Movie Trailers and News
  • Paste.ie

Footer

Site hosted in Ireland by Blacknight - Content copyright Michele Neylon

Copyright © 2025 · Magazine Pro on Genesis Framework · WordPress · Log in