Contao-Camp 2024
Ergebnis 1 bis 15 von 15

Thema: .htaccess - web oder root?

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

    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
    14.548
    User beschenken
    Wunschliste
    Contao-Projekt unterstützen

    Support Contao

    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
    471

    Standard

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

  4. #4
    Wandelndes Contao-Lexikon Avatar von tab
    Registriert seit
    22.10.2013.
    Beiträge
    10.060
    Contao-Projekt unterstützen

    Support Contao

    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
    14.548
    User beschenken
    Wunschliste
    Contao-Projekt unterstützen

    Support Contao

    Standard

    Poste Deine .htaccess.
    Contao Community Administrator

    [Unterstützungsmöglichkeiten]

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

    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
    Wandelndes Contao-Lexikon Avatar von tab
    Registriert seit
    22.10.2013.
    Beiträge
    10.060
    Contao-Projekt unterstützen

    Support Contao

    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

  8. #8
    Contao-Nutzer
    Registriert seit
    21.01.2014.
    Ort
    Kiel
    Beiträge
    131

    Standard Ähnliches Problem:

    Hielfähh, meine Regel "remove WWW" greift auch nicht. (c4.9.41 / php 7.4 / htaccess im web folder). Funktionierte in der c3.x Version - sollte also nicht an DF/PHPini settings liegen... Ich möchte, eine www-Bereinigung erreichen (Zeile 4ff). Hat jemand eine Idee?

    Code:
    <IfModule mod_rewrite.c>
        RewriteEngine On
        
        # REMOVE WWW 
    	RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    	RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
    	RewriteCond %{HTTPS} !on
    	RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    
        <IfModule mod_headers.c>
            # Assets in /assets and /bundles either contain a hash in their filename
            # or are called with a ?version suffix, therefore cache them for 1 year.
            RewriteRule ^(assets|bundles)/ - [ENV=CONTAO_ASSETS:true]
            Header set Cache-Control "max-age=31536000" env=CONTAO_ASSETS
    
            # Allow CORS on the Contao TinyMCE skin.
            RewriteRule ^assets/tinymce4/js/skins/contao/fonts/ - [ENV=CONTAO_TINYMCE_SKIN:true]
            Header set Access-Control-Allow-Origin "*" env=CONTAO_TINYMCE_SKIN
        </IfModule>
    
        # 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 index.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}]
    
        # Redirect to URI without front controller to prevent duplicate content
        # (with and without `/index.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 ^index\.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}/index.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 ^/$ /index.php/
            # RedirectTemp cannot be used instead
        </IfModule>
    </IfModule>

  9. #9
    Contao-Nutzer
    Registriert seit
    21.01.2014.
    Ort
    Kiel
    Beiträge
    131

    Standard

    *Gelöst*
    Es lag noch ein TXT-Record (ohne A-Record) mit "www" in den Nameserver Einstellungen rum, der mal zur temporären Domain Verifizierung gedacht war. Gelöscht => läuft

  10. #10
    Contao-Fan Avatar von Schneetiger
    Registriert seit
    26.01.2013.
    Beiträge
    278

    Standard

    Jetzt habe ich noch ein paar Fragen dazu.

    Ich habe für einen Kunden auf dessen Entwicklungsseite gerade von C 4.9 auf C 4.13 ein Upgrade durchgeführt und möchte definitiv verhindern, dass irgendeine Suchmaschine diese Seite indiziert; sie wurde auch nie angemeldet.

    Frage 1: Soll ich in die .htaccess "no index, no follow" eintragenb oder sehe ich hier "Probleme", die es so nicht gibt?
    Frage 2: Wenn doch, dann müsste das sicherlich auch direkt unter "RewriteEngine On" stehen?
    Frage 3: Muss ich dazu eine neuen Thread aufmachen?

    Danke für Eure Unterstützung.

  11. #11
    Community-Moderator Avatar von stefan-at-work
    Registriert seit
    05.06.2009.
    Ort
    Bad Segeberg
    Beiträge
    1.780
    Partner-ID
    634

    Standard

    einfach Verzeichnisschutz auf web oder public einrichten


    Gesendet von iPhone mit Tapatalk

  12. #12
    Contao-Fan Avatar von Schneetiger
    Registriert seit
    26.01.2013.
    Beiträge
    278

    Standard

    Läuft das dann so ab, wie hier https://community.contao.org/de/show...eichnis-Schutz beschrieben und alles eingefügt direkt unter "RewriteEngine On"?

    Habe unter der dem Startpunkt einer Website der robots.txt bereits folgende Anweisung implementiert:

    User-agent: *
    Disallow: /

    Das sollte doch vor einer Indexierung seitens Google and Sisters schützen?
    Geändert von Schneetiger (12.05.2023 um 13:46 Uhr)

  13. #13
    Community-Moderatorin & Contao-Urgestein Avatar von mlweb
    Registriert seit
    10.07.2011.
    Beiträge
    6.715
    Contao-Projekt unterstützen

    Support Contao

    Standard

    Das ist quasi ein Wunsch. Daran hält sich nicht jeder.
    Willst Du eine Seite wirksam schützen, dann mit Verzeichnisschutz.
    Ich habe Dir mit meinen Hinweisen geholfen und Du möchtest Dich bedanken?
    Unterstütze bitte das Contao-Projekt (Button Links)
    Weitere Spendenmöglichkeiten
    ------------------------------------------------------------------------------------------------------
    Contao-Dokumentation: Contao-Handbuch und Contao-Entwickler-Doku
    Contao-Online-Video-Kurse: Contao Academy
    Funktionalität erweitern: Contao-Erweiterungen

    Für Dinge die man mit html5 und css3 lösen kann, braucht man kein javascript.




  14. #14
    Contao-Fan Avatar von mdoll
    Registriert seit
    25.06.2009.
    Ort
    Wietze
    Beiträge
    334

    Standard

    Moin,

    Verzeichnisschutz, ohne an der htaccess rumzufummeln:
    https://packagist.org/packages/termi...oot-protection

    Gruß
    Mathias
    “Ah," said Mr Pin. "Right. I remember. You are concerned citizens." He knew about concerned citizens. Wherever they were, they all spoke the same private language, where 'traditional values' meant 'hang someone'.”
    ― Terry Pratchett, The Truth

  15. #15
    Contao-Fan Avatar von Schneetiger
    Registriert seit
    26.01.2013.
    Beiträge
    278

    Standard

    @mlweb & @mdoll & stefan-at-work:

    Vielen Dank für Eure Unterstützung; ich werde alle Vorschläge mal ausprobieren.

    LG
    Schneetiger

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
  •