fixed missing apache rewrite in root
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
3573e23212
commit
4a9a3eec06
@ -76,15 +76,18 @@ func (node *TreeNode) ProcessContent() {
|
||||
curNavPath = ""
|
||||
}
|
||||
|
||||
goTo := node.Config.This.GoTo
|
||||
if goTo != nil && *goTo != "" {
|
||||
goToFixed := *goTo
|
||||
if strings.HasPrefix(goToFixed, "/") {
|
||||
goToFixed = helper.BackToRoot(curNavPath) + goToFixed
|
||||
}
|
||||
goToFixed = path.Clean(goToFixed)
|
||||
if node.root != node {
|
||||
// write htaccess for rewrites, root will be written in WriteWebserverConfig()
|
||||
goTo := node.Config.This.GoTo
|
||||
if goTo != nil && *goTo != "" {
|
||||
goToFixed := *goTo
|
||||
if strings.HasPrefix(goToFixed, "/") {
|
||||
goToFixed = helper.BackToRoot(curNavPath) + goToFixed
|
||||
}
|
||||
goToFixed = path.Clean(goToFixed)
|
||||
|
||||
htaccessRedirect(node.OutputPath, goToFixed)
|
||||
htaccessRedirect(node.OutputPath, goToFixed)
|
||||
}
|
||||
}
|
||||
|
||||
for _, file := range node.InputFiles {
|
||||
|
@ -3,6 +3,7 @@ package mark2web
|
||||
import (
|
||||
"io/ioutil"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"gitbase.de/apairon/mark2web/pkg/helper"
|
||||
)
|
||||
@ -22,10 +23,27 @@ RewriteRule ^$ %{REQUEST_URI}`+goTo+`/ [R,L]
|
||||
}
|
||||
|
||||
// WriteWebserverConfig build the config for pre compression and more
|
||||
func WriteWebserverConfig() {
|
||||
func (tree *TreeNode) WriteWebserverConfig() {
|
||||
goTo := ""
|
||||
if g := tree.Config.This.GoTo; g != nil && *g != "" {
|
||||
goTo = strings.TrimPrefix(*g, "/")
|
||||
}
|
||||
|
||||
switch Config.Webserver.Type {
|
||||
case "apache":
|
||||
configStr := `
|
||||
RewriteEngine on
|
||||
|
||||
`
|
||||
|
||||
if goTo != "" {
|
||||
configStr += `
|
||||
RewriteRule ^$ %{REQUEST_URI}` + goTo + `/ [R,L]
|
||||
|
||||
`
|
||||
}
|
||||
|
||||
configStr += `
|
||||
AddCharset UTF-8 .html
|
||||
AddCharset UTF-8 .json
|
||||
AddCharset UTF-8 .js
|
||||
@ -34,8 +52,6 @@ AddCharset UTF-8 .css
|
||||
RemoveLanguage .br
|
||||
|
||||
<IfModule mod_headers.c>
|
||||
|
||||
RewriteEngine on
|
||||
`
|
||||
|
||||
rewriteMacro := func(e, c, x, xx string) string {
|
||||
|
@ -10,7 +10,7 @@ func Run(inDir, outDir string, defaultPathConfig *PathConfig) {
|
||||
|
||||
ProcessAssets()
|
||||
|
||||
WriteWebserverConfig()
|
||||
tree.WriteWebserverConfig()
|
||||
|
||||
Wait()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user