Skip to content

Commit 65f837e

Browse files
committed
Switch to temporary redirect for URL rewrites
* Allows us to revert to ASCII URLs if/when we migrate to a platform that supports them
1 parent 0c9a447 commit 65f837e

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

nginx.conf.sigil

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434

3535
# Determine if the URL needs conversion by checking if it contains non-ASCII characters.
3636
map $uri $needs_conversion {
37-
~[^\x00-\x7F] "yes";
38-
default "no";
37+
~[^\x00-\x7F] "yes";
38+
default "no";
3939
}
4040

4141
server {
@@ -98,8 +98,9 @@ server {
9898
-- First check for Medium ID and remove it before processing
9999
local has_medium_id = string.match(ngx.var.uri, "/(.*)-([%x][%x][%x][%x][%x][%x][%x][%x][%x][%x][%x]?[%x]?)$")
100100
if has_medium_id then
101-
-- Remove Medium ID and redirect to the cleaned URL
101+
-- Remove Medium ID
102102
local clean_path = string.gsub(ngx.var.uri, "/(.*)-([%x][%x][%x][%x][%x][%x][%x][%x][%x][%x][%x]?[%x]?)$", "/%1")
103+
-- Permanent redirect since the Medium ID doesn't mean much on any other platform
103104
ngx.redirect(clean_path, 301)
104105
return
105106
end
@@ -150,7 +151,8 @@ server {
150151
local converted_path = convert_string(original_path)
151152

152153
-- Redirect to the converted path
153-
ngx.redirect("/" .. converted_path, 301)
154+
-- Only do a temporary redirect allowing us to revert to ASCII URLs in future
155+
ngx.redirect("/" .. converted_path, 307)
154156
return
155157
end
156158
}
@@ -177,7 +179,7 @@ server {
177179
}
178180

179181
upstream {{ .APP }} {
180-
{{ range .DOKKU_APP_WEB_LISTENERS | split " " }}
181-
server {{ . }};
182-
{{ end }}
182+
{{ range .DOKKU_APP_WEB_LISTENERS | split " " }}
183+
server {{ . }};
184+
{{ end }}
183185
}

0 commit comments

Comments
 (0)