I have Wordpress on nginx that serves blogposts from www.helenagwyn.com/blog/... . I want to move my blog to helenagwyn.blog/... . The rest of the pages will remain on helenagwyn.com. Is there a way to automatically redirect a request for helenagwyn.com/blog/... to helenagwyn.blog/... ?

  • sean replied to this.

    HelenaGwyn we've got some redirection features on the todo list, but for now you can do it by setting up a separate app to serve the redirect.

    Here's how:

    1. Go to https://my.opalstack.com/apps/ and click "Create Application".
    2. Enter an app name like "helenagwyn_blog_redirect" (ignore the placeholder text that reads "username", we'll have that fixed soon).
    3. Select "PHP-CGI with Apache" as the app type (so we can use .htaccess later).
    4. Select the shell user that currently serves the apps on helenagwyn.com.
    5. Click the "Create Application" button and wait a few seconds for the app to be created.
    6. Create a file /home/shelluser/apps/helenagwyn_blog_redirect/.htaccess (replace shelluserwith the following contents:

      RewriteEngine on
      RewriteRule ^(.*)$ https://helenagwyn.blog/$1 [R=301,L]
    1. Go to https://my.opalstack.com/domains/ and click the edit icon for your site.
    2. Click the purple "Route Application" button.
    3. Select your "helenagwyn_blog_redirect" app from the list.
    4. Enter /blog in the field next to the selected application.
    5. Click the green "Update site" button to save your changes.

    Your redirect should begin working a few seconds after you complete those steps.

    Hope this helps 🙂

    a month later

    Apparently I was mistaken. The blogposts are served from the root as in "helenagwyn.com/2021/06/06/title". Do I create applications for each year? Or is the best and other solution to turn the app in a PHP-CGI with Apache so I can serve the .htaccess for the root?

    • sean replied to this.

      HelenaGwyn you shouldn't need to create a separate app for each year.

      The ^(.*)$ means "match the entire URI path", meaning the part after the domain.

      The $1 inserts that matched value into the destination URL for the redirect.

      If the original blog at helenagwyn.com/blog/ used the same permalink format then the redirect that you have ought to be working.

      Feel free to contact support via email if you need us to take a closer look. Thanks!

      5 months later

      For future reference I wanted to share I used the plugin https://wordpress.org/plugins/redirection/ with the following rules:

      Redirect catgories
      ^/category/(.*)$ tohttps://helenagwyn.blog/categorie/$1

      Redirect blogposts
      ^(\/[0-9]{4}\/[0-9]{2}\/[0-9]{2}\/.*)$ to https://helenagwyn.blog/$1

      Mastodon