source/Setup/Utilities.php
public function updateHtaccessFile($aParams, $sSubFolder = "")
    {
        /** @var \OxidEsales\EshopCommunity\Setup\Language $oLang */
        $oLang = $this->getInstance("Language");

        // preparing rewrite base param
        if (!isset($aParams["sBaseUrlPath"]) || !$aParams["sBaseUrlPath"]) {
            $aParams["sBaseUrlPath"] = "";
        }

        if ($sSubFolder) {
            $sSubFolder = $this->preparePath("/" . $sSubFolder);
        }

        $aParams["sBaseUrlPath"] = trim($aParams["sBaseUrlPath"] . $sSubFolder, "/");
        $aParams["sBaseUrlPath"] = "/" . $aParams["sBaseUrlPath"];

        $sHtaccessPath = $this->preparePath($aParams["sShopDir"]) . $sSubFolder . "/.htaccess";

        clearstatcache();
        if (!file_exists($sHtaccessPath)) {
            throw new Exception(sprintf($oLang->getText('ERROR_COULD_NOT_FIND_FILE'), $sHtaccessPath), Utilities::ERROR_COULD_NOT_FIND_FILE);
        }

        @chmod($sHtaccessPath, getDefaultFileMode());
        if (is_readable($sHtaccessPath) && ($fp = fopen($sHtaccessPath, "r"))) {
            $sHtaccessFile = fread($fp, filesize($sHtaccessPath));
            fclose($fp);
        } else {
            throw new Exception(sprintf($oLang->getText('ERROR_COULD_NOT_READ_FILE'), $sHtaccessPath), Utilities::ERROR_COULD_NOT_READ_FILE);
        }

        // overwriting settings
        $sHtaccessFile = preg_replace("/RewriteBase.*/", "RewriteBase " . $aParams["sBaseUrlPath"], $sHtaccessFile);
        if (is_writable($sHtaccessPath) && ($fp = fopen($sHtaccessPath, "w"))) {
            fwrite($fp, $sHtaccessFile);
            fclose($fp);
        } else {
            // error ? strange !?
            throw new Exception(sprintf($oLang->getText('ERROR_COULD_NOT_WRITE_TO_FILE'), $sHtaccessPath), Utilities::ERROR_COULD_NOT_WRITE_TO_FILE);
        }
    }
public function updateHtaccessFile($aParams, $sSubFolder = "")
    {
        /** @var \OxidEsales\EshopCommunity\Setup\Language $oLang */
        $oLang = $this->getInstance("Language");

        // preparing rewrite base param
        if (!isset($aParams["sBaseUrlPath"]) || !$aParams["sBaseUrlPath"]) {
            $aParams["sBaseUrlPath"] = "";
        }

        if ($sSubFolder) {
            $sSubFolder = $this->preparePath("/" . $sSubFolder);
        }

        $aParams["sBaseUrlPath"] = trim($aParams["sBaseUrlPath"] . $sSubFolder, "/");
        $aParams["sBaseUrlPath"] = "/" . $aParams["sBaseUrlPath"];

        $sHtaccessPath = $this->preparePath($aParams["sShopDir"]) . $sSubFolder . "/.htaccess";

        clearstatcache();
        if (!file_exists($sHtaccessPath)) {
            throw new Exception(sprintf($oLang->getText('ERROR_COULD_NOT_FIND_FILE'), $sHtaccessPath), Utilities::ERROR_COULD_NOT_FIND_FILE);
        }

        @chmod($sHtaccessPath, getDefaultFileMode());
        if (is_readable($sHtaccessPath) && ($fp = fopen($sHtaccessPath, "r"))) {
            $sHtaccessFile = fread($fp, filesize($sHtaccessPath));
            fclose($fp);
        } else {
            throw new Exception(sprintf($oLang->getText('ERROR_COULD_NOT_READ_FILE'), $sHtaccessPath), Utilities::ERROR_COULD_NOT_READ_FILE);
        }

        // overwriting settings
        $sHtaccessFile = preg_replace("/RewriteBase.*/", "RewriteBase " . $aParams["sBaseUrlPath"], $sHtaccessFile);
        if (is_writable($sHtaccessPath) && ($fp = fopen($sHtaccessPath, "w"))) {
            fwrite($fp, $sHtaccessFile);
            fclose($fp);
        } else {
            // error ? strange !?
            throw new Exception(sprintf($oLang->getText('ERROR_COULD_NOT_WRITE_TO_FILE'), $sHtaccessPath), Utilities::ERROR_COULD_NOT_WRITE_TO_FILE);
        }
    }
public function updateHtaccessFile ( $ aParams , $ sSubFolder = "" ) { /** @var \OxidEsales\EshopCommunity\Setup\Language $oLang */ $ oLang = $ this -> getInstance ( "Language" ) ; // preparing rewrite base param if ( ! isset ( $ aParams [ "sBaseUrlPath" ] ) || ! $ aParams [ "sBaseUrlPath" ] ) { $ aParams [ "sBaseUrlPath" ] = "" ; } if ( $ sSubFolder ) { $ sSubFolder = $ this -> preparePath ( "/" . $ sSubFolder ) ; } $ aParams [ "sBaseUrlPath" ] = trim ( $ aParams [ "sBaseUrlPath" ] . $ sSubFolder , "/" ) ; $ aParams [ "sBaseUrlPath" ] = "/" . $ aParams [ "sBaseUrlPath" ] ; $ sHtaccessPath = $ this -> preparePath ( $ aParams [ "sShopDir" ] ) . $ sSubFolder . "/.htaccess" ; clearstatcache ( ) ; if ( ! file_exists ( $ sHtaccessPath ) ) { throw new Exception ( sprintf ( $ oLang -> getText ( 'ERROR_COULD_NOT_FIND_FILE' ) , $ sHtaccessPath ) , Utilities :: ERROR_COULD_NOT_FIND_FILE ) ; } @ chmod ( $ sHtaccessPath , getDefaultFileMode ( ) ) ; if ( is_readable ( $ sHtaccessPath ) && ( $ fp = fopen ( $ sHtaccessPath , "r" ) ) ) { $ sHtaccessFile = fread ( $ fp , filesize ( $ sHtaccessPath ) ) ; fclose ( $ fp ) ; } else { throw new Exception ( sprintf ( $ oLang -> getText ( 'ERROR_COULD_NOT_READ_FILE' ) , $ sHtaccessPath ) , Utilities :: ERROR_COULD_NOT_READ_FILE ) ; } // overwriting settings $ sHtaccessFile = preg_replace ( "/RewriteBase.*/" , "RewriteBase " . $ aParams [ "sBaseUrlPath" ] , $ sHtaccessFile ) ; if ( is_writable ( $ sHtaccessPath ) && ( $ fp = fopen ( $ sHtaccessPath , "w" ) ) ) { fwrite ( $ fp , $ sHtaccessFile ) ; fclose ( $ fp ) ; } else { // error ? strange !? throw new Exception ( sprintf ( $ oLang -> getText ( 'ERROR_COULD_NOT_WRITE_TO_FILE' ) , $ sHtaccessPath ) , Utilities :: ERROR_COULD_NOT_WRITE_TO_FILE ) ; } }
Updates default htaccess file with user defined params

@param array  $aParams    various setup parameters
@param string $sSubFolder in case you need to update non default, but e.g. admin file, you must add its folder

@throws Exception when .htaccess file is not accessible/readable.
Updates default htaccess file with user defined params