Apache, konfigurieren für Typo3 und normale Webseiten

hga

New Member
Hier mein .conf File für die Typo3-Konfiguration.
Code:
<VirtualHost *:80>
    ServerAdmin <email>
    DocumentRoot /var/www/typo3/public
    Servername <domain.de>
    <Directory /var/www/typo3/public/>
          Options FollowSymlinks
          AllowOverride All
          Require all granted
     </Directory>

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined

     <Directory /var/www/typo3/public/>
            RewriteEngine on
            RewriteBase /
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^(.*) index.php [PT,L]
    </Directory>
</VirtualHost>

Soweit ich es bisher verstanden habe, nuss man dafür einen weiteren VirtualHost nach dem bestehenden definieren.
Aber wie?
DocumentRoot des 2. VirtalHost soll /car/www/html sein.
 
Im Prinzip musst du einen weiteren Virtual Host wie den oben genannten erstellen. Darin musst du dann die Werte für DocumentRoot und ServerName anpassen sowie den Verzeichnisnamen im ersten Directory Block. Den zweiten Directory Block kannst du wahrscheinlich weglassen, da die Rewrite-Regeln für Typo sein dürften.
Den virtuellen Host kannst du in die vorhandene Datei unter den bereits vorhandenen einfügen oder auch eine neue Datei verwenden. Hier kommt es auch ein wenig auf die verwendete Linux-Distribution an.
Bei Debian und Ubuntu erstellt man für jeden virtuellen Host eine eigene Datei unter /etc/apache2/sites-available und aktiviert die einzelnen virtuellen Hosts über den Befehl a2ensite <Datei>. Bei anderen Distributionen kann es etwas anders sein.
Falls du separate Log-Dateien pro virtuellem Host haben willst, musst du auch noch die beiden Zeilen mit customlog und errorlog entsprechend anpassen. Abhängig von dem Inhalt der zweiten Webseite müssen evtl. weiter Konfigurationen in den virtuellen Host eingetragen werden.
 
Ich verwende Debian.
Ich würde gerne den gleichen Domain-Namen verwenden.
Bisher habe ich Windows verwendet und in der web root Directory gibt es ein web.config File, welches festlegt, wann die Anforderung an Typo3 index.php weitergeleitet und wann nicht.
Ist soetwas mit Apache auch möglich?
Hier das web.config file:
XML:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <httpProtocol>
            <customHeaders>
                <add name="Access-Control-Allow-Origin" value="*" />            
                <add name="X-UA-Compatible" value="IE=edge" />
                <add name="Cache-Control" value="Public" />
            </customHeaders>
        </httpProtocol>
        <rewrite>
            <rules>
                <clear />
                <rule name="HTTPS Rewrite" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{HTTPS}" pattern="^OFF$" />
                    </conditions>
                    <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" />
                </rule>
                <rule name="Add WWW" stopProcessing="true">
                    <match url="^(.*)$" />
                        <conditions>
                            <add input="{HTTP_HOST}" pattern="^(?!www\.)(.*)$" />
                        </conditions>
                    <action type="Redirect" url="https://www.{C:0}{PATH_INFO}" redirectType="Permanent" />
                </rule>
                <rule name="TYPO3 - Block access to composer files">
                    <match url="composer\.(?:json|lock)" ignoreCase="true" />
                    <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
                </rule>
                <rule name="TYPO3 - Block access to flexform files">
                    <match url="flexform[^.]*\.xml" ignoreCase="true" />
                    <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
                </rule>
                <rule name="TYPO3 - Block access to language files">
                    <match url="locallang[^.]*\.(?:xml|xlf)$" ignoreCase="true" />
                    <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
                </rule>
                <rule name="TYPO3 - Block access to static typoscript files">
                    <match url="ext_conf_template\.txt|ext_typoscript_constants\.txt|ext_typoscript_setup\.txt" ignoreCase="true" />
                    <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
                </rule>
                <rule name="TYPO3 - Block access to miscellaneous protected files">
                    <match url="/.*\.(?:bak|co?nf|cfg|ya?ml|ts|typoscript|tsconfig|dist|fla|in[ci]|log|sh|sql|sqlite)$" ignoreCase="true" />
                    <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
                </rule>
                <rule name="TYPO3 - Block access to recycler and temporary directories">
                    <match url="_(?:recycler|temp)_/" ignoreCase="false" />
                    <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
                </rule>
                <rule name="TYPO3 - Block access to configuration files stored in fileadmin">
                    <match url="fileadmin/(?:templates)/.*\.(?:txt|ts)$" ignoreCase="false" />
                    <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
                </rule>
                <rule name="TYPO3 - Block access to libraries, source and temporary compiled data">
                    <match url="^(?:vendor|typo3_src|typo3temp/var)" ignoreCase="false" />
                    <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
                </rule>
                <rule name="TYPO3 - Block access to protected extension directories">
                    <match url="(?:typo3conf/ext|typo3/sysext|typo3/ext)/[^/]+/(?:Configuration|Resources/Private|Tests?|Documentation|docs?)/" ignoreCase="false" />
                    <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
                </rule>
                <rule name="TYPO3 - Static File Directories" stopProcessing="true">
                    <match url="^/(typo3temp|typo3conf|t3lib|tslib|fileadmin|uploads|showpic\.php|favicon\.ico)$" />
                    <action type="None" />
                </rule>
                <rule name="TYPO3 - If the file/directory does not exist but is below /typo3/, redirect to the TYPO3 Backend entry point." stopProcessing="true">
                    <match url="^typo3/(.*)$" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                        <add input="{REQUEST_URI}" matchType="Pattern" pattern="^/typo3/.*$" />
                    </conditions>
                    <action type="Rewrite" url="typo3/index.php" appendQueryString="true" />
                </rule>
                <rule name="TYPO3 - Version Number in File Name (if set)" stopProcessing="true">
                    <match url="^(.+)\.(\d+)\.(php|js|css|png|jpg|gif|gzip)$" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="{R:1}.{R:3}" />
                </rule>
                <rule name="TYPO3 - If the file/directory does not exist => Redirect to index.php." stopProcessing="true">
                    <match url="^.*$" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php" appendQueryString="true" />
                </rule>

            </rules>
        </rewrite>
        <staticContent>
            <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="8.00:00:00" />
<!--             <mimeMap fileExtension="." mimeType="text/xml" /> -->
        </staticContent>
        <security>
            <requestFiltering>
                <requestLimits maxAllowedContentLength="525000000" />
            </requestFiltering>
        </security>
    </system.webServer>
</configuration>
 
Ich verwende Debian.
Ich würde gerne den gleichen Domain-Namen verwenden.
Bisher habe ich Windows verwendet und in der web root Directory gibt es ein web.config File, welches festlegt, wann die Anforderung an Typo3 index.php weitergeleitet und wann nicht.
Ist soetwas mit Apache auch möglich?
Hier das web.config file:
XML:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <httpProtocol>
            <customHeaders>
                <add name="Access-Control-Allow-Origin" value="*" />           
                <add name="X-UA-Compatible" value="IE=edge" />
                <add name="Cache-Control" value="Public" />
            </customHeaders>
        </httpProtocol>
        <rewrite>
            <rules>
                <clear />
                <rule name="HTTPS Rewrite" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{HTTPS}" pattern="^OFF$" />
                    </conditions>
                    <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" />
                </rule>
                <rule name="Add WWW" stopProcessing="true">
                    <match url="^(.*)$" />
                        <conditions>
                            <add input="{HTTP_HOST}" pattern="^(?!www\.)(.*)$" />
                        </conditions>
                    <action type="Redirect" url="https://www.{C:0}{PATH_INFO}" redirectType="Permanent" />
                </rule>
                <rule name="TYPO3 - Block access to composer files">
                    <match url="composer\.(?:json|lock)" ignoreCase="true" />
                    <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
                </rule>
                <rule name="TYPO3 - Block access to flexform files">
                    <match url="flexform[^.]*\.xml" ignoreCase="true" />
                    <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
                </rule>
                <rule name="TYPO3 - Block access to language files">
                    <match url="locallang[^.]*\.(?:xml|xlf)$" ignoreCase="true" />
                    <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
                </rule>
                <rule name="TYPO3 - Block access to static typoscript files">
                    <match url="ext_conf_template\.txt|ext_typoscript_constants\.txt|ext_typoscript_setup\.txt" ignoreCase="true" />
                    <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
                </rule>
                <rule name="TYPO3 - Block access to miscellaneous protected files">
                    <match url="/.*\.(?:bak|co?nf|cfg|ya?ml|ts|typoscript|tsconfig|dist|fla|in[ci]|log|sh|sql|sqlite)$" ignoreCase="true" />
                    <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
                </rule>
                <rule name="TYPO3 - Block access to recycler and temporary directories">
                    <match url="_(?:recycler|temp)_/" ignoreCase="false" />
                    <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
                </rule>
                <rule name="TYPO3 - Block access to configuration files stored in fileadmin">
                    <match url="fileadmin/(?:templates)/.*\.(?:txt|ts)$" ignoreCase="false" />
                    <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
                </rule>
                <rule name="TYPO3 - Block access to libraries, source and temporary compiled data">
                    <match url="^(?:vendor|typo3_src|typo3temp/var)" ignoreCase="false" />
                    <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
                </rule>
                <rule name="TYPO3 - Block access to protected extension directories">
                    <match url="(?:typo3conf/ext|typo3/sysext|typo3/ext)/[^/]+/(?:Configuration|Resources/Private|Tests?|Documentation|docs?)/" ignoreCase="false" />
                    <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
                </rule>
                <rule name="TYPO3 - Static File Directories" stopProcessing="true">
                    <match url="^/(typo3temp|typo3conf|t3lib|tslib|fileadmin|uploads|showpic\.php|favicon\.ico)$" />
                    <action type="None" />
                </rule>
                <rule name="TYPO3 - If the file/directory does not exist but is below /typo3/, redirect to the TYPO3 Backend entry point." stopProcessing="true">
                    <match url="^typo3/(.*)$" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                        <add input="{REQUEST_URI}" matchType="Pattern" pattern="^/typo3/.*$" />
                    </conditions>
                    <action type="Rewrite" url="typo3/index.php" appendQueryString="true" />
                </rule>
                <rule name="TYPO3 - Version Number in File Name (if set)" stopProcessing="true">
                    <match url="^(.+)\.(\d+)\.(php|js|css|png|jpg|gif|gzip)$" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="{R:1}.{R:3}" />
                </rule>
                <rule name="TYPO3 - If the file/directory does not exist => Redirect to index.php." stopProcessing="true">
                    <match url="^.*$" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php" appendQueryString="true" />
                </rule>

            </rules>
        </rewrite>
        <staticContent>
            <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="8.00:00:00" />
<!--             <mimeMap fileExtension="." mimeType="text/xml" /> -->
        </staticContent>
        <security>
            <requestFiltering>
                <requestLimits maxAllowedContentLength="525000000" />
            </requestFiltering>
        </security>
    </system.webServer>
</configuration>
 
Die web.config ist für den IIS von Microsoft. Apache kennt sowas auch, dort wird eine .htaccess Datei verwendet oder die Regeln stehen direkt im Virtual Host drin - in deinem Falls der zweite Directory Block scheint in die Richtung zu gehen. Ich habe allerdings nie mit Typo gearbeitet und kann dir daher nicht sagen, ob das schon ausreicht. .htaccess und web.config verwenden aber komplett unterschiedliche Syntax-Regeln
Virtuelle Hosts sind dafür da, dass unter unterschiedlichen Domains unterschiedliche Inhalte verfügbar sind (das können auch Subdomains der gleichen Domain sein, also z.B. www.domain.de und intern.domain.de). Das ist ja das Entscheidungsmerkmal, anhand dessen der Webserver die Anfragen dem jeweiligen virtuellen Host zuordnet. Daher darf der Eintrag bei "ServerName" oder dessen Bruder "ServerAlias" nur einmal in sämtlichen vHosts vorkommen.
Wenn du bei deinem Beispiel im 1. Post bei
Code:
ServerName domain.de
stehen hast, kannst du beispielsweise darunter eine Zeile einfügen, mit
Code:
ServerAlias www.domain.de
eintragen, damit der virtuelle Host auch für die www Subdomain gilt.
Für alle Anfragen, bei denen es keinen passenden Eintrag in ServerName oder ServerAlias gibt, wird der erste virtuelle Host der kompletten Apache-Konfiguration verwendet (bei Debian i.d.R. der in der Datei /etc/apache2/sites-available/00-default.conf) - die anderen Dateien bekommen dann (um bei meinem Beispiel zu bleiben) die Namen www.domain.de.conf und intern.domain.de.conf. Die Dateinamen sind nur für dich als Admin zur Orientierung, für Apache ist nur der Inhalt entscheidend.
 
Back
Top