redirect via apache rewrite engine
All checks were successful
the build was successful

This commit is contained in:
Sebastian Frank 2019-02-15 15:05:48 +01:00
parent 6e4a680237
commit ba9634a72c
Signed by: apairon
GPG Key ID: 7270D06DDA7FE8C3
2 changed files with 14 additions and 2 deletions

View File

@ -27,7 +27,7 @@
<li {% if nav.Active %}class="active"{% endif %}><a href="{{ nav.GoTo }}" title="{{ nav.This.Data.hoverText }}">{{ nav.Navname }}</a>
{% if nav.SubSlice %}
<ul>
{% for nav2 in SubSlice %}
{% for nav2 in nav.SubSlice %}
<li {% if nav2.Active %}class="active"{% endif %}><a href="{{ nav2.GoTo }}" title="{{ nav2.This.Data.hoverText }}">{{ nav2.Navname }}</a>
</li>
{% endfor %}

14
main.go
View File

@ -330,8 +330,20 @@ func processContent(conf *PathConfigTree) {
if strings.HasPrefix(goToFixed, "/") {
goToFixed = backToRoot(curNavPath) + goToFixed
}
goToFixed = path.Clean(goToFixed)
log.Error(goToFixed)
switch globalConfig.Webserver.Type {
case "apache":
htaccessFile := conf.OutputPath + "/.htaccess"
log.Noticef("writing '%s' with redirect to: %s", htaccessFile, goToFixed)
err := ioutil.WriteFile(htaccessFile, []byte(`RewriteEngine on
RewriteRule ^$ %{REQUEST_URI}`+goToFixed+`/ [R,L]
`), 0644)
if err != nil {
log.Panicf("could not write '%s': %s", htaccessFile, err)
}
break
}
}
for _, file := range conf.InputFiles {