Redirect `prefix.website.com` to `website.com/prefix`

I want to redirect guidebooks.jcarpinelli.dev/controls to jcarpinelli.dev/guidebooks/controls. Is this possible with any Zola features today?

I see redirect_to, and aliases, but they seem to be slightly different.

That would be something you do at the DNS level, not in Zola.

I think this is at the HTML level, no? CNAME only supports pointing to IP addresses. I think this feature is redirecting through HTML.

Ah sorry yes. But this is not something Zola supports

Hi @cadojo,

redirects are things that happen at the HTTP level, ie the webserver.

You can configure this in the webserver guidebooks.jcarpinelli.dev

You need to know the type of webserver(Apache?) or service(netlify, other) and look in its documentation. Look for the term HTTP redirect.

You can also do HTML redirects (eg the Zola aliases etc) but it’s not as good as HTTP redirects.

You could use HTML redirects, if your domain setup process is very homogenous, and it’s actually easier for you to create a webroot to simply contain an index.html that redirects, I’m not sure if you’d need Zola to generate that HTML file. Extending Zola to distribute static redirect dummies to multiple public/ directories feels like using the wrong tool.

The way I do static redirects is in my webserver, which happens to be nginx. This is the same way I make the http:// version redirect to the https:// version. In nginx the redirect would look like:

server {
    listen 80;
    server_name guidebooks.jcarpinelli.dev;
    return 301 https://jcarpinelli/guidebooks$request_uri;
}

Here, HTTP 301 is Moved Permanently.

Now, you might want to also have https enabled for this domain even though it’s only used for redirection, simply to not have to show a red lock icon for some split seconds while redirection. If you think maintaining redirections in your webserver configuration is too much bother, having a static index.html that just contains the redirect is a simple, workable solution. But then you don’t dynamically get forwarding for every possible request uri.