<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Nginx on Janusworx</title><link>https://janusworx.com/tags/nginx/</link><description>Recent content in Nginx on Janusworx</description><generator>Hugo -- gohugo.io</generator><language>en</language><managingEditor>feedback@janusworx.com (Mario Jason Braganza)</managingEditor><webMaster>feedback@janusworx.com (Mario Jason Braganza)</webMaster><copyright>© 2026, Mario Jason Braganza</copyright><lastBuildDate>Mon, 22 Jul 2019 13:40:35 +0530</lastBuildDate><atom:link href="https://janusworx.com/tags/nginx/index.xml" rel="self" type="application/rss+xml"/><item><title>NGINX Redirect .html to just slugs</title><link>https://janusworx.com/work/nginx-redirect-html-to-just-slugs/</link><pubDate>Mon, 22 Jul 2019 13:40:35 +0530</pubDate><author>feedback@janusworx.com (Mario Jason Braganza)</author><guid>https://janusworx.com/work/nginx-redirect-html-to-just-slugs/</guid><description>&lt;p&gt;I like Nikola’s pretty URLs feature and have been using it at the &lt;a href="https://mjbraganza.com" target="_blank" rel="noreferrer"&gt;personal site&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;And after a year of prettiness there and .html here, I decided to switch this site to use it too.&lt;br&gt;
All my urls look nice now :)&lt;br&gt;
Which also means all the old links are now broken.&lt;br&gt;
And so, the last bit of work was to redirect all the links in the wild and on the blog to the new addresses&lt;/p&gt;
&lt;p&gt;A quick web search led me to this &lt;a href="https://stackoverflow.com/questions/24225145/nginx-remove-php-and-html-file-extension/32966347#32966347" target="_blank" rel="noreferrer"&gt;stackoverflow answer&lt;/a&gt;.&lt;/p&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#at the top of location /
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;if ($request_uri ~ ^/(.*)\.html$) { return 302 /$1; }
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#within \.php$
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;if ($request_uri ~ ^/([^?]*)\.php($|\?)) { return 302 /$1?$args; }&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/br&gt;
&lt;p&gt;&lt;s&gt;All I needed was the top bit and all was well, with my world :)&lt;/s&gt;&lt;/p&gt;
&lt;p&gt;Update: Gave up on the redirect idea, beacause it was breaking pagination on the blog. Well, I tried :)&lt;/p&gt;</description></item></channel></rss>