Use superblog on a subdirectory or subfolder

Hey there,
It looks like you want to use superblog on a subdirectory or subfolder on your domain.
example: yoursite.com/blog

However, we highly recommend you to use superblog on a subdomain (blog.yoursite.com) because only then you can take full benefits of superblog like

  1. Free SSL
  2. CDN (your blog will be really fast)
  3. High performance (your blog will never slow down with an increase in traffic)
  4. Super easy setup

If you still want to use superblog on a subdirectory (like this yoursite.com/blog), then no problem, please follow the below steps.

  1. Your main domain needs to be using Nginx or similar software.
  2. You need to add a reverse proxy configuration.
  3. Your SSL should be configured properly.
  4. Copy the below config (nginx) in your server block.
  5. Read this: Blog hosting: subdomain vs subfolder | Superblog
 # added for reverse proxying superblog
location /blog/ { # you can use different slugs instead of /blog/ ex: content, knowledge, learn
                rewrite ^([^.]*[^/])$ $1/ permanent;
                sub_filter_once off;
                sub_filter_types *;
                sub_filter /_elderjs /blog/_elderjs;
                proxy_ssl_verify off;
                proxy_set_header Host "example.superblog.cloud";
                proxy_set_header X-Forwarded-Host "";
                proxy_set_header X-Forwarded-For "";
                proxy_set_header Accept-Encoding "";
                proxy_set_header Cookie "";
                proxy_ssl_server_name on;
                proxy_pass https://example.superblog.cloud/;
                proxy_redirect ~^(http://[^/]+)(/.*)$ https://$http_host$2;
 }
  1. Restart your nginx and clear cache in your browser. Your superblog will be available at your new URL.
  2. Write an email to hello<@>superblog.ai with your config and confirmation to enable subdirectory hosting. We get back to you in 24 working hours.

Just remember that by using the above method the performance of superblog will depend on your server’s speed to handle the reverse proxy connection and you will lose advantage of superblog’s CDN too. But this is a fairly common practice for using any other blogging software like Wordpress or ghost too. To improve this, you can cloudflare DNS or AWS Cloudfront or similar software.

Vercel:

vercel.json config:

{
  "routes": [
    {
      "src": "/blog",
      "dest": "https://example.superblog.cloud" # you will get this value via email   
    },
    {
      "src": "/blog/(.*?)([.]\\w{2,5})(\\?[^/]+)?",
      "dest": "https://example.superblog.cloud/$1$2$3"
    },
    {
      "src": "/blog/([\\S\\s]+)",
      "dest": "https://example.superblog.cloud/$1/"
    },
    {
      "src": "/_elderjs/svelte/(.*?)([.]\\w{2,5})(\\?[^/]+)?",
      "dest": "https://example.superblog.cloud/_elderjs/svelte/$1$2$3"
    },
    {
      "src": "/_elderjs/svelte/([\\S\\s]+)",
      "dest": "https://example.superblog.cloud/_elderjs/svelte/$1/"
    },
    {
      "src": "/.netlify/functions/(.*?)([.]\\w{2,5})(\\?[^/]+)?",
      "dest": "https://example.superblog.cloud/.netlify/functions/$1$2$3"
    },
    {
      "src": "/.netlify/functions/([\\S\\s]+)",
      "dest": "https://example.superblog.cloud/.netlify/functions/$1/"
    }
  ]
}

Netlify

netlify.toml config:

[[redirects]]
  from = "/blog/*"
  to = "https://example.superblog.cloud/:splat"
  status = 200

[[redirects]]
  from = "/_elderjs/*"
  to = "https://example.superblog.cloud/_elderjs/:splat"
  status = 200