From 33ac6d26cf3f01bb92eb69a55a3848492225cb4b Mon Sep 17 00:00:00 2001 From: billz Date: Tue, 2 Mar 2021 14:37:50 +0000 Subject: [PATCH] Fix for #803 by @mp035 --- config/50-raspap-router.conf | 8 ++++---- installers/common.sh | 22 +++++++++++++++++++--- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/config/50-raspap-router.conf b/config/50-raspap-router.conf index 31ac6b1a..c7634436 100644 --- a/config/50-raspap-router.conf +++ b/config/50-raspap-router.conf @@ -2,8 +2,8 @@ server.modules += ( "mod_rewrite", ) -$HTTP["url"] =~ "^/(?!(dist|app|ajax|config)).*" { - url.rewrite-once = ( - "^/[^\?]*(\?.*)?" => "/index.php$1" - ) +$HTTP["url"] =~ "^/REPLACE_ME/(?!(dist|app|ajax|config)).*" { + url.rewrite-once = ( "^/REPLACE_ME/(.*?)(\?.+)?$"=>"/REPLACE_ME/index.php/$1?$2" ) + server.error-handler-404 = "/REPLACE_ME/index.php" } + diff --git a/installers/common.sh b/installers/common.sh index cf3883e1..dba8a0b9 100755 --- a/installers/common.sh +++ b/installers/common.sh @@ -208,14 +208,30 @@ function _install_lighttpd_configs() { # Copy config files echo "Copying 50-raspap-router.conf to /etc/lighttpd/conf-available" - sudo cp "$webroot_dir/config/50-raspap-router.conf" "/etc/lighttpd/conf-available" || _install_status 1 "Unable to copy lighttpd config file." + + CONFSRC="$webroot_dir/config/50-raspap-router.conf" + LTROOT=$(grep "server.document-root" /etc/lighttpd/lighttpd.conf | awk -F '=' '{print $2}' | tr -d " \"") + + # compare values and get difference + HTROOT=${webroot_dir/$LTROOT} + + # remove trailing slash if present + HTROOT=$(echo "$HTROOT" | sed -e 's/\/$//') + + # substitute values + awk "{gsub(\"/REPLACE_ME\",\"$HTROOT\")}1" $CONFSRC > /tmp/50-raspap-router.conf + + # copy into place + sudo cp /tmp/50-raspap-router.conf /etc/lighttpd/conf-available/ || _install_status 1 "Unable to copy lighttpd config file into place." + # link into conf-enabled - echo "Creating link to /etc/lighttpd/conf-enabled"|| _install_status 1 "Unable to copy lighttpd config file." - sudo ln -s "/etc/lighttpd/conf-available/50-raspap-router.conf" "/etc/lighttpd/conf-enabled/50-raspap-router.conf" || _install_status 1 "Unable to symlink lighttpd config file." + echo "Creating link to /etc/lighttpd/conf-enabled" + sudo ln -s "/etc/lighttpd/conf-available/50-raspap-router.conf" "/etc/lighttpd/conf-enabled/50-raspap-router.conf" || _install_status 1 "Unable to symlink lighttpd config file (this is normal if the link already exists)." sudo systemctl restart lighttpd.service || _install_status 1 "Unable to restart lighttpd" _install_status 0 } + # Prompt to install ad blocking function _prompt_install_adblock() { _install_log "Configure ad blocking (Beta)"