How I Got Clean URLs For My Blog


 • 

General

Technology

A simple and effective solution for SEO-friendly URLs that can be used with virtually any web app.

placeholder.png

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.


Also on: