Skip to content

Commit 75c4f4b

Browse files
fix: do not redirect baseURL to itself (Apache)
Signed-off-by: Daniel F. Dickinson <dfdpublic@wildtechgarden.ca>
1 parent 50407e8 commit 75c4f4b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

layouts/home.apache_htaccess

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ ErrorDocument 404 /404.html
1616

1717
<IfModule mod_rewrite.c>
1818
RewriteEngine On
19+
{{- $siteUrl := urls.Parse site.BaseURL }}
1920
{{- $redirectMap := partial "collect-redirects.html" . }}
2021
{{- range $status, $redirects := $redirectMap }}
2122
{{- if reflect.IsMap $redirects }}
2223
{{- range $from, $to := $redirects }}
2324
{{- $url := urls.Parse $from }}
24-
{{- if $url.Scheme }}
25+
{{- if and $url.Scheme (ne $siteUrl.Host $url.Host) }}
2526
RewriteCond %{HTTP_HOST} ^{{ $url.Host }}$
2627
RewriteRule (.*) {{ site.BaseURL }}$1 [QSA,END,R=301]
2728
{{- end }}

0 commit comments

Comments
 (0)