How I Got Clean URLs For My Blog

Return to home page.

Published: January 9, 2020

Like many people and organizations, my site has portions that are powered by open source software. An example of that would be the code powering this blog my old blog, from tilde.team (with permission from Ben, of course).

This code worked, for the most part, but URLs were written like

https://www.antonmcclure.com/blog/?page=name

rather than an SEO-friendly

https://www.antonmcclure.com/blog/name

In order to fix this, some NGINX code is needed.

The rewrite code that worked for me is shown below:

        location /blog/ {
                rewrite ^/blog/(.*)$ /blog/index.php?page=$1 last;
        }

Feel free to use and adapt this in your NGINX configs as you deem necessary.


Anton McClure / anton@tilde.pw
Page last updated on: 11 August 2020 @ 23:18:15 UTC (+0000)