Using .htaccess for permanent redirects

I have been running an older version of Ground School that was based on WordPress at https://www.morzaviation.com for some time now. I kept both applications running simultaneously to give users a chance to move over to Ground School on their own time, but software doesn’t die easily. Even with the massive improvements to UX and performance in Ground School which is a .NET Core application, compared to the old WordPress-based plugin mess of an application, some users still kept using https://www.morzaviation.com because they were comfortable with how it worked.

Unfortunately, it wasn’t possible to maintain two applications anymore, especially considering they are written in two different programming languages, and when updating WordPress, often plugins have issues updating or something changes which breaks things. Therefore https://www.morzaviation.com was not been maintained as well as Ground School – it was just kept running well-enough so that it was usable. Eventually though, due to security and time-requirements, I had to make the decision to shut it down for good.

Now came the problem of redirecting users to the new site at https://www.groundschool.aero. As I do not have much experience managing Apache servers, I found this part to be a bit tricky, as using just a normal redirect meant that any additions to the URL such as /shop or ?postId=xxx also stayed on the URL when redirecting. I wanted all URLs that point to https://www.morzaviation.com to redirect to https://www.groundschool.aero. Eventually I figured out what I needed to do.

I had to create a .htaccess file in the root directory of the webserver (the public_html directory) and then add the following lines to this file.

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule .* https://www.groundschool.aero/? [R=301,L]

If you got here because you need to do the same thing and this file already exists for you, then add these lines to the top of the file, also replace the https://www.groundschool.aero/ with your URL.

Leave a comment

Your email address will not be published.