Contao Camp 2019 in München - Save the date!
Ergebnis 1 bis 7 von 7

Thema: .htaccess - web oder root?

  1. #1
    Contao-Fan
    Registriert seit
    10.11.2010.
    Beiträge
    329

    Standard .htaccess - web oder root?

    Hallo,

    ich werde gerade aus den bisherigen Foreneinträgen nicht schlau. Wohin muss die .htaccess bei Contao 4.X? Ins Verzeichnis /web/? Und ist das so korrekt (mit www und immer mit https):

    Code:
        # Sets the HTTP_AUTHORIZATION header removed by Apache
        RewriteCond %{HTTP:Authorization} .
        RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
        RewriteCond %{SERVER_PORT} 80
        RewriteRule ^(.*)$ https://www.domain.com/$1 [R=301,L]
    Vielen Dank für die Antworten!

  2. #2
    Administrator Avatar von xchs
    Registriert seit
    19.06.2009.
    Beiträge
    13.379
    User beschenken
    Wunschliste

    Standard

    Ja, die .htaccess muss in das web/ Unterverzeichnis (welches Dein DocumentRoot ist)
    Contao Community Administrator
    [Unterstützungsmöglichkeiten]

  3. #3
    Contao-Fan
    Registriert seit
    10.11.2010.
    Beiträge
    329

    Standard

    Ok, scheinbar greift die Datei an dieser Stelle nicht. Oder ist die .htaccess-Anweisung nicht korrekt?

  4. #4
    Contao-Urgestein
    Registriert seit
    22.10.2013.
    Beiträge
    7.778
    User beschenken
    Wunschliste

    Standard

    Du sooltest deine eigenen Rewrites oben nach RewriteEngine On einfügen.

  5. #5
    Administrator Avatar von xchs
    Registriert seit
    19.06.2009.
    Beiträge
    13.379
    User beschenken
    Wunschliste

    Standard

    Poste Deine .htaccess.
    Contao Community Administrator
    [Unterstützungsmöglichkeiten]

  6. #6
    Contao-Fan
    Registriert seit
    10.11.2010.
    Beiträge
    329

    Standard

    Hab ich ja, ab zeile 25 nach dem %{HTTP:Authorization}-Block (siehe erstes Posting).

    - - - Aktualisiert - - -

    Code:
    <IfModule mod_headers.c>
        # Allow access from all domains for webfonts (see contao/core-bundle#528)
        <FilesMatch "\.(ttf|ttc|otf|eot|woff2?|font\.css)$">
            Header set Access-Control-Allow-Origin "*"
        </FilesMatch>
    </IfModule>
    
    <IfModule mod_rewrite.c>
        RewriteEngine On
    
        # Determine the RewriteBase automatically and set it as environment variable.
        # If you are using Apache aliases to do mass virtual hosting or installed the
        # project in a subdirectory, the base path will be prepended to allow proper
        # resolution of the app.php file and to redirect to the correct URI. It will
        # work in environments without path prefix as well, providing a safe, one-size
        # fits all solution. But as you do not need it in this case, you can comment
        # the following 2 lines to eliminate the overhead.
        RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
        RewriteRule ^(.*) - [E=BASE:%1]
    
        # Sets the HTTP_AUTHORIZATION header removed by Apache
        RewriteCond %{HTTP:Authorization} .
        RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    	
    	RewriteCond %{SERVER_PORT} !=443
    	RewriteRule ^(.*)$ https://www.domain.com/$1 [R=301,L]
    
        # Redirect to URI without front controller to prevent duplicate content
        # (with and without `/app.php`). Only do this redirect on the initial
        # rewrite by Apache and not on subsequent cycles. Otherwise we would get an
        # endless redirect loop (request -> rewrite to front controller ->
        # redirect -> request -> ...).
        # So in case you get a "too many redirects" error or you always get redirected
        # to the start page because your Apache does not expose the REDIRECT_STATUS
        # environment variable, you have 2 choices:
        # - disable this feature by commenting the following 2 lines or
        # - use Apache >= 2.3.9 and replace all L flags by END flags and remove the
        #   following RewriteCond (best solution)
        RewriteCond %{ENV:REDIRECT_STATUS} ^$
        RewriteRule ^app\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
    
        # If the requested filename exists, simply serve it.
        # We only want to let Apache serve files and not directories.
        RewriteCond %{REQUEST_FILENAME} -f
        RewriteRule ^ - [L]
    
        # Rewrite all other queries to the front controller.
        RewriteRule ^ %{ENV:BASE}/app.php [L]
    
    </IfModule>
    
    <IfModule !mod_rewrite.c>
        <IfModule mod_alias.c>
            # When mod_rewrite is not available, we instruct a temporary redirect of
            # the start page to the front controller explicitly so that the website
            # and the generated links can still be used.
            RedirectMatch 302 ^/$ /app.php/
            # RedirectTemp cannot be used instead
        </IfModule>
    </IfModule>
    
    # Set cache-control
        <IfModule mod_expires.c>
            ExpiresActive On
            ExpiresDefault "access plus 1 week"
            ExpiresByType text/html "access plus 1 week"
            ExpiresByType image/gif "access plus 1 year"
            ExpiresByType image/jpeg "access plus 1 year"
            ExpiresByType image/jpg "access plus 1 year"
            ExpiresByType image/png "access plus 1 year"
            ExpiresByType image/x-png "access plus 1 year"
            ExpiresByType text/css "access plus 1 year"
            ExpiresByType text/javascript "access plus 1 year"
            ExpiresByType application/x-javascript "access plus 1 year"
            ExpiresByType application/javascript "access plus 1 year"
            ExpiresByType image/x-icon "access plus 1 year"
            ExpiresByType video/ogg "access plus 1 year"
    		ExpiresByType audio/ogg "access plus 1 year"
    		ExpiresByType video/mp4 "access plus 1 year"
    		ExpiresByType video/webm "access plus 1 year"
    		ExpiresByType application/x-font-ttf "access plus 1 year"
    		ExpiresByType application/font-woff2 "access plus 1 year"
    		ExpiresByType application/x-font-woff "access plus 1 year"
    		ExpiresByType image/svg+xml "access plus 1 year"
        </IfModule>
    
    <IfModule mod_deflate.c>
    	AddOutputFilterByType DEFLATE text/plain
    	AddOutputFilterByType DEFLATE text/html
    	AddOutputFilterByType DEFLATE text/xml
    	AddOutputFilterByType DEFLATE text/shtml
    	AddOutputFilterByType DEFLATE text/css
    	AddOutputFilterByType DEFLATE application/xml
    	AddOutputFilterByType DEFLATE application/xhtml+xml
    	AddOutputFilterByType DEFLATE application/rss+xml
    	AddOutputFilterByType DEFLATE application/javascript
    	AddOutputFilterByType DEFLATE application/x-javascript
    </IfModule>

  7. #7
    Contao-Urgestein
    Registriert seit
    22.10.2013.
    Beiträge
    7.778
    User beschenken
    Wunschliste

    Standard

    Zitat Zitat von Dublay Beitrag anzeigen
    Hab ich ja, ab zeile 25 nach dem %{HTTP:Authorization}-Block (siehe erstes Posting).
    Davor, direkt unterhalb RewriteEngine On

Aktive Benutzer

Aktive Benutzer

Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)

Lesezeichen

Lesezeichen

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •