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/index.php b/index.php index 87b0c8b8..b69f89b9 100755 --- a/index.php +++ b/index.php @@ -49,7 +49,7 @@ require_once 'includes/torproxy.php'; $config = getConfig(); $output = $return = 0; -$page = $_SERVER['REQUEST_URI']; +$page = $_SERVER['PATH_INFO']; $theme_url = getThemeOpt(); $toggleState = getSidebarState(); 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)"