Ergebnis 1 bis 18 von 18

Thema: Startseite kann auch über Alias aufgerufen werden (duplicate content), 301 geht nicht

  1. #1
    Gesperrt
    Registriert seit
    14.10.2012.
    Ort
    München
    Beiträge
    63

    Standard Startseite kann auch über Alias aufgerufen werden (duplicate content), 301 geht nicht

    Hallo,

    bei Anlegen meiner neuen Website habe ich der ersten Seite (nicht dem Startpunkt) den Alias „index“ gegeben. So wird die „Home“ auch in der sitemap.xml korrekt angezeigt, nämlich

    <url><loc>https://www.example.com/</loc></url>

    und nicht

    <url><loc>https://www.example.com/index</loc></url>

    (ich nutze das URL-Suffix „html“ nicht)

    So weit alles gut, aber ich habe zwei Probleme:

    1.
    Trotzdem existiert aber diese Seite und lässt sich mit
    www.example.com/index
    auch aufrufen.

    Das kann als duplicate content interpretiert werden, was ich unbedingt vermeiden möchte.

    Ein Redirect in der .htaccess
    Code:
    Redirect 301 /index https://www.example.com/
    scheitert: die Seite ist trotzdem aufzurufen und wird nicht umgeleitet.

    2.
    Ein Redirect für die alte Seite (noch mit Suffix „html“)
    Code:
    Redirect 301 /index.html https://www.example.com/
    lässt mich gar nicht mehr auf die Startseite zugreifen.

    Da diese alte URL aber bei Suchmaschinen im Index steht, wäre diese Umleitung schon sehr nützlich.

    Dankeschön im Voraus für Eure Tipps!
    Alexandra

  2. #2
    Community-Moderator
    Wandelndes Contao-Lexikon
    Avatar von Spooky
    Registriert seit
    12.04.2012.
    Ort
    Scotland
    Beiträge
    34.100
    Partner-ID
    10107

    Standard

    Sollte beides eigentlich ohne Probleme funktionieren. Habe es auch lokal getestet. Also mit
    Code:
    Redirect 301 /index https://www.example.org/
    Redirect 301 /index.html https://www.example.org/


    Zitat Zitat von Alexandra Beitrag anzeigen
    Das kann als duplicate content interpretiert werden, was ich unbedingt vermeiden möchte.
    Höchstwahrscheinlich aber nicht als böswilliger duplicate content. Das passiert nur bei gleichem Inhalt über mehrere Domains hinweg.
    Geändert von Spooky (19.06.2016 um 11:16 Uhr)

  3. #3
    Gesperrt
    Registriert seit
    14.10.2012.
    Ort
    München
    Beiträge
    63

    Standard

    Zitat Zitat von Spooky Beitrag anzeigen
    Sollte beides eigentlich ohne Probleme funktionieren. Habe es auch lokal getestet. Also mit
    Code:
    Redirect 301 /index https://www.example.org/
    Redirect 301 /index.html https://www.example.org/
    Bei mir geht es leider nicht. Könnte es sein, dass es sich mit anderen Codeschnipseln in der .htaccess nicht verträgt, z.B.:
    Code:
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    # …
    RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
    RewriteRule (.*) http://www.example.com/$1 [R=301,L]
    # …
    RewriteCond %{REQUEST_FILENAME} !\.(htm|php|js|css|htc|png|gif|jpe?g|ico|xml|csv|txt|swf|flv|mp4|webm|ogv|mp3|ogg|oga|eot|otf|tt[cf]|woff2?|svgz?|pdf|gz)$
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule .* index.php [L]
    (das ist das, was ich an der .htaccess noch verändert habe)

  4. #4
    Community-Moderator
    Wandelndes Contao-Lexikon
    Avatar von Spooky
    Registriert seit
    12.04.2012.
    Ort
    Scotland
    Beiträge
    34.100
    Partner-ID
    10107

    Standard

    Poste mal die gesamte .htaccess

  5. #5
    Gesperrt
    Registriert seit
    14.10.2012.
    Ort
    München
    Beiträge
    63

    Standard

    Hier die ganze .htaccess

    Code:
    AddHandler php56-cgi .php
    ##
    # SSL Alex
    ##
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    
    ##
    # Redirects (->SSL) Alex
    ##
    Redirect 301 /index https://www.example.com/
    #Redirect 301 /index.html https://www.example.com
    Redirect 301 /home https://www.example.com/
    Redirect 301 /ueber-mich.html https://www.example.com/ueber-mich
    Redirect 301 /blog.html https://www.example.com/blog
    Redirect 301 /blog-archiv.html https://www.example.com/blog-archiv?year=2016
    Redirect 301 /kalender.html https://www.example.com/kalender
    Redirect 301 /impressum.html https://www.example.com/impressum
    Redirect 301 /datenschutz.html https://www.example.com/datenschutz
    Redirect 301 /sitemap.html https://www.example.com/sitemap
    
    ##
    # Contao Open Source CMS
    #
    # Copyright (c) 2005-2015 Leo Feyer
    #
    # @license LGPL-3.0+
    ##
    
    ##
    # Prevent access to the Contao template files
    ##
    <FilesMatch "\.(tpl|html5|xhtml)$">
      <IfModule !mod_authz_core.c>
        Order deny,allow
        Deny from all
      </IfModule>
      <IfModule mod_authz_core.c>
        Require all denied
      </IfModule>
    </FilesMatch>
    
    ##
    # Allow access from all domains for webfonts
    # @see https://github.com/h5bp/html5-boilerplate
    ##
    <IfModule mod_headers.c>
      <FilesMatch "\.(ttf|ttc|otf|eot|woff2?|font\.css)$">
        Header set Access-Control-Allow-Origin "*"
      </FilesMatch>
    </IfModule>
    
    ##
    # Disable ETags
    # @see http://developer.yahoo.com/performance/rules.html#etags
    ##
    FileETag None
    <IfModule mod_headers.c>
      Header unset ETag
    </IfModule>
    
    ##
    # Set the proper MIME types
    # @see https://github.com/h5bp/html5-boilerplate
    ##
    <IfModule mod_mime.c>
      AddType application/javascript              js jsonp
      AddType application/json                    json
      AddType audio/ogg                           oga ogg
      AddType audio/mp4                           m4a f4a f4b
      AddType video/ogg                           ogv
      AddType video/mp4                           mp4 m4v f4v f4p
      AddType video/webm                          webm
      AddType video/x-flv                         flv
      AddType image/svg+xml                       svg svgz
      AddEncoding gzip                            svgz
      AddType application/vnd.ms-fontobject       eot
      AddType application/x-font-ttf              ttf ttc
      AddType font/opentype                       otf
      AddType application/x-font-woff             woff woff2
      AddType image/x-icon                        ico
      AddType image/webp                          webp
      AddType text/cache-manifest                 appcache manifest
      AddType text/x-component                    htc
      AddType application/xml                     rss atom xml rdf
      AddType application/x-web-app-manifest+json webapp
      AddType text/x-vcard                        vcf
      AddType application/x-shockwave-flash       swf
    </IfModule>
    
    ##
    # Gzip compression
    # @see https://github.com/h5bp/html5-boilerplate
    ##
    <IfModule mod_deflate.c>
      <IfModule mod_filter.c>
        AddOutputFilterByType DEFLATE text/html text/plain text/css application/json
        AddOutputFilterByType DEFLATE application/javascript
        AddOutputFilterByType DEFLATE text/xml application/xml text/x-component
        AddOutputFilterByType DEFLATE application/xhtml+xml application/rss+xml application/atom+xml
        AddOutputFilterByType DEFLATE image/x-icon image/svg+xml application/vnd.ms-fontobject application/x-font-ttf font/opentype
      </IfModule>
    </IfModule>
    
    ##
    # Expires headers (for better cache control)
    # @see https://github.com/h5bp/html5-boilerplate
    ##
    <IfModule mod_expires.c>
      ExpiresActive on
    
      ##
      # Productional website
      ##
      ExpiresByType text/cache-manifest           "access plus 0 seconds"
      ExpiresByType text/html                     "access plus 0 seconds"
      ExpiresByType text/xml                      "access plus 0 seconds"
      ExpiresByType application/xml               "access plus 0 seconds"
      ExpiresByType application/json              "access plus 0 seconds"
      ExpiresByType application/rss+xml           "access plus 1 hour"
      ExpiresByType application/atom+xml          "access plus 1 hour"
      ExpiresByType image/gif                     "access plus 1 month"
      ExpiresByType image/png                     "access plus 1 month"
      ExpiresByType image/jpeg                    "access plus 1 month"
      ExpiresByType image/x-icon                  "access plus 1 month"
      ExpiresByType video/ogg                     "access plus 1 month"
      ExpiresByType audio/ogg                     "access plus 1 month"
      ExpiresByType video/mp4                     "access plus 1 month"
      ExpiresByType video/webm                    "access plus 1 month"
      ExpiresByType text/x-component              "access plus 1 month"
      ExpiresByType application/x-font-ttf        "access plus 1 month"
      ExpiresByType font/opentype                 "access plus 1 month"
      ExpiresByType application/x-font-woff       "access plus 1 month"
      ExpiresByType image/svg+xml                 "access plus 1 month"
      ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
      ExpiresByType text/css                      "access plus 1 year"
      ExpiresByType application/javascript        "access plus 1 year"
    
      ##
      # Disable caching during development
      # @see https://github.com/contao/core/issues/4364
      ##
      #ExpiresByType text/cache-manifest           "access"
      #ExpiresByType text/html                     "access"
      #ExpiresByType text/xml                      "access"
      #ExpiresByType application/xml               "access"
      #ExpiresByType application/json              "access"
      #ExpiresByType application/rss+xml           "access"
      #ExpiresByType application/atom+xml          "access"
      #ExpiresByType image/gif                     "access"
      #ExpiresByType image/png                     "access"
      #ExpiresByType image/jpeg                    "access"
      #ExpiresByType image/x-icon                  "access"
      #ExpiresByType video/ogg                     "access"
      #ExpiresByType audio/ogg                     "access"
      #ExpiresByType video/mp4                     "access"
      #ExpiresByType video/webm                    "access"
      #ExpiresByType text/x-component              "access"
      #ExpiresByType application/x-font-ttf        "access"
      #ExpiresByType font/opentype                 "access"
      #ExpiresByType application/x-font-woff       "access"
      #ExpiresByType image/svg+xml                 "access"
      #ExpiresByType application/vnd.ms-fontobject "access"
      #ExpiresByType text/css                      "access"
      #ExpiresByType application/javascript        "access"
    
    </IfModule>
    
    ##
    # Header adjustments
    ##
    <IfModule mod_headers.c>
    
      ##
      # Disable caching during development
      # @see https://github.com/contao/core/issues/4364
      ##
      #Header unset Cache-Control
      #Header append Cache-Control must-revalidate
    
      ##
      # Do not cache the cron.txt file
      # @see https://github.com/contao/core/issues/5105
      ##
      <FilesMatch "cron\.txt$">
        Header set Cache-Control "no-cache, no-store, must-revalidate, max-age=0, proxy-revalidate, no-transform"
      </FilesMatch>
    
      ##
      # Add a Vary Accept-Encoding header for the compressed resources. If you
      # modify the file types above, make sure to change them here accordingly.
      # @see http://developer.yahoo.com/performance/rules.html#gzip
      #
      # Note: If you are using a case-sensitive file system like HFS+ or ext4, you
      # have to change the <FilesMatch> directive as follows:
      #
      # <FilesMatch "\.(?i:js|css|xml|gz|svgz)$">
      #
      # For more information see: https://github.com/contao/core/issues/4364
      ##
      <FilesMatch "\.(js|css|xml|gz|svgz)$">
        Header append Vary Accept-Encoding
      </FilesMatch>
    
    </IfModule>
    
    ##
    # Disable MultiViews if you are having issues with requests returning the wrong
    # page. Requires AllowOverride Options=All,MultiViews to be set here.
    # @see https://github.com/contao/core/issues/3521
    ##
    #Options -MultiViews
    
    ##
    # URL rewriting
    ##
    <IfModule mod_rewrite.c>
      RewriteEngine On
    
      ##
      # Change the RewriteBase if your Contao installation is in a subdirectoy and
      # the rewrite rules are not working properly. Usage examples:
      #
      #   RewriteBase /contao-3.0.0
      #   RewriteBase /path/to/contao
      #
      # Depending on your server, you might have to remove the line entirely.
      ##
      RewriteBase /
    
      ##
      # Uncomment the following lines to add "www." to the domain:
      #
      RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
      RewriteRule (.*) http://www.example.com/$1 [R=301,L]
      #
      # Uncomment the following lines to remove "www." from the domain:
      #
      #   RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
      #   RewriteRule (.*) http://example.com/$1 [R=301,L]
      #
      # Make sure to replace "example.com" with your domain name.
      ##
    
      ##
      # If you cannot use mod_deflate, uncomment the following lines to load a
      # compressed .gz version of the aggregated Contao JavaScript and CSS files.
      ##
      #AddEncoding gzip .gz
      #<FilesMatch "\.js\.gz$">
      #  AddType "application/javascript" .gz
      #</FilesMatch>
      #<FilesMatch "\.css\.gz$">
      #  AddType "text/css" .gz
      #</FilesMatch>
      #RewriteCond %{HTTP:Accept-encoding} gzip
      #RewriteCond %{REQUEST_FILENAME} \.(js|css)$
      #RewriteCond %{REQUEST_FILENAME}.gz -f
      #RewriteRule ^(.*)$ $1.gz [QSA,L]
    
      ##
      # By default, Contao adds ".html" to the generated URLs to simulate static
      # HTML documents. If you change the URL suffix in the back end settings, make
      # sure to change it here accordingly!
      #
      #   RewriteRule .*\.html$ index.php [L]   # URL suffix .html
      #   RewriteRule .*\.txt$ index.php [L]    # URL suffix .txt
      #   RewriteRule .*\.json$ index.php [L]   # URL suffix .json
      #
      # If you do not want to use an URL suffix at all, you have to add a third
      # line to prevent URLs that point to folders from being rewritten (see #4031).
      #
      #   RewriteCond %{REQUEST_FILENAME} !-d
      #   RewriteRule .* index.php [L]
      #
      # If you are using mod_cache, it is recommended to use the RewriteRule below,
      # which adds the query string to the internal URL:
      #
      #   RewriteRule (.*\.html)$ index.php/$1 [L]
      #
      # Note that not all environments support mod_rewrite and mod_cache.
      ##
      RewriteCond %{REQUEST_FILENAME} !\.(htm|php|js|css|htc|png|gif|jpe?g|ico|xml|csv|txt|swf|flv|mp4|webm|ogv|mp3|ogg|oga|eot|otf|tt[cf]|woff2?|svgz?|pdf|gz)$
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule .* index.php [L]
    
      ##
      # The following rules are required if you want to pass the language as first
      # URL parameter (added in Contao 2.11). The first rule rewrites the empty URL
      # to the front end controller, the second one adds a missing trailing slash.
      ##
      RewriteRule ^[a-z]{2}(\-[A-Z]{2})?/$ index.php [L]
      RewriteRule ^([a-z]{2}(\-[A-Z]{2})?)$ $1/ [R=301,L]
    
    </IfModule>
    Der Redirect 301 /index.html ist absichtlich auskommentiert, da sonst im Browser folgende Fehlermeldung erscheint:
    Beim Öffnen von … traten zu viele Umleitungen auf.
    Dies ist möglich, wenn die geöffnete Seite auf eine andere Seite umleitet, die wieder zurück auf die Ursprungsseite verweist.
    Nur leider kann ich nicht erkennen, wo ich doppelt umleite :-(

    Dankeschön für’s Anschauen.

  6. #6
    Community-Moderator
    Wandelndes Contao-Lexikon
    Avatar von Spooky
    Registriert seit
    12.04.2012.
    Ort
    Scotland
    Beiträge
    34.100
    Partner-ID
    10107

    Standard

    Diesen Teil
    Code:
    ##
    # SSL Alex
    ##
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    könntest du vielleicht eher hinter diesen Teil
    Code:
      ##
      # Uncomment the following lines to add "www." to the domain:
      #
      RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
      RewriteRule (.*) http://www.example.com/$1 [R=301,L]
      #
      # Uncomment the following lines to remove "www." from the domain:
      #
      #   RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
      #   RewriteRule (.*) http://example.com/$1 [R=301,L]
      #
      # Make sure to replace "example.com" with your domain name.
      ##
    setzen und dann natürlich
    Code:
    RewriteEngine On
    entfernen. Darüberhinaus solltest du hier
    Code:
      RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
      RewriteRule (.*) http://www.example.com/$1 [R=301,L]
    direkt auf https redirecten lassen, also[code] RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
    RewriteRule (.*) https://www.example.com/$1 [R=301,L]damit nicht unnötigerweise zwei Redirects passieren.

    Ansonsten sehe ich eigentlich kein Problem
    Code:
    Redirect 301 /index https://www.example.com/
    Redirect 301 /index.html https://www.example.com
    sollte funktionieren. Wo du das in der .htaccess hinschreibst, sollte auch egal sein.

  7. #7
    Gesperrt
    Registriert seit
    14.10.2012.
    Ort
    München
    Beiträge
    63

    Standard

    Dankeschön, spooky, für die Tipps!
    Damit ist schon mal eine doppelte Umleitung weg und die .htaccess viel aufgeräumter!
    Aber leider existieren die beiden geschilderten Probleme immer noch.
    :-(
    Geändert von Alexandra (23.06.2016 um 11:10 Uhr)

  8. #8
    Contao-Nutzer Avatar von Der Astronaut
    Registriert seit
    20.07.2012.
    Ort
    Weltall
    Beiträge
    241

    Standard

    Ich stehe aktuell vor dem selben Problem.

    In meinem Fall habe ich
    Code:
    ReWriteRule ^index(\/)?$ / [R=301,L]
    probiert. Funktioniert aber nicht, wenn ich domain.de/index eingebe.

    Was aber funktioniert ist

    Code:
    ReWriteRule ^index / [R=301,L]
    Es wird zwar auf root umgeleitet, aber dafür funktionieren sämtliche andere Links nicht mehr.

    Regelt das mit dem "index" als Alias Contao vielleicht selbst? Hat das irgendwas mit der index.php zu tun, die ja in meiner zweiten Regel auch ansprechbar ist?

    Ich habs in zwei Contao 3.5.15-Installationen versucht. Beide mit Ordner-URL, aber ohne Suffix. Bei einer der Installationen ist die htaccess geradezu jungfräulich.

  9. #9
    Community-Moderator
    Wandelndes Contao-Lexikon
    Avatar von Spooky
    Registriert seit
    12.04.2012.
    Ort
    Scotland
    Beiträge
    34.100
    Partner-ID
    10107

    Standard

    Zitat Zitat von Der Astronaut Beitrag anzeigen
    Es wird zwar auf root umgeleitet, aber dafür funktionieren sämtliche andere Links nicht mehr.
    Was genau geht dann nicht mehr?

  10. #10
    Contao-Nutzer Avatar von Der Astronaut
    Registriert seit
    20.07.2012.
    Ort
    Weltall
    Beiträge
    241

    Standard

    Andere Unterseiten werden auf root umgeleitet.

    Beispiel: domain.de/news leitet auf domain.de um. Oder domain.de/impressum leitet auf domain.de um usw.

  11. #11
    Community-Moderator
    Wandelndes Contao-Lexikon
    Avatar von Spooky
    Registriert seit
    12.04.2012.
    Ort
    Scotland
    Beiträge
    34.100
    Partner-ID
    10107

    Standard

    Code:
    Redirect 301 /index https://www.example.org
    wäre wohl einfacher (wie schon in meinem Post davor erwähnt).

  12. #12
    Contao-Nutzer Avatar von Der Astronaut
    Registriert seit
    20.07.2012.
    Ort
    Weltall
    Beiträge
    241

    Standard

    Hatte ich auch probiert. Wird aber nicht umgeleitet.

    Mit meiner Regel wollte ich zudem ein eventuell abschließenden Slash vorbeugen.

    Du kannst dir gerne die htaccess von der "jungfräulichen" Installation ansehen. Da habe ich nur den URL-Rewriting-Part bearbeitet.

    Code:
    ##
    # Contao Open Source CMS
    #
    # Copyright (c) 2005-2016 Leo Feyer
    #
    # @license LGPL-3.0+
    ##
    
    ##
    # Prevent access to the Contao template files
    ##
    <FilesMatch "\.(tpl|html5|xhtml)$">
      <IfModule !mod_authz_core.c>
        Order deny,allow
        Deny from all
      </IfModule>
      <IfModule mod_authz_core.c>
        Require all denied
      </IfModule>
    </FilesMatch>
    
    ##
    # Allow access from all domains for webfonts
    # @see https://github.com/h5bp/html5-boilerplate
    ##
    <IfModule mod_headers.c>
      <FilesMatch "\.(ttf|ttc|otf|eot|woff2?|font\.css)$">
        Header set Access-Control-Allow-Origin "*"
      </FilesMatch>
    </IfModule>
    
    ##
    # Disable ETags
    # @see http://developer.yahoo.com/performance/rules.html#etags
    ##
    FileETag None
    <IfModule mod_headers.c>
      Header unset ETag
    </IfModule>
    
    ##
    # Set the proper MIME types
    # @see https://github.com/h5bp/html5-boilerplate
    ##
    <IfModule mod_mime.c>
      AddType application/javascript              js jsonp
      AddType application/json                    json
      AddType audio/ogg                           oga ogg
      AddType audio/mp4                           m4a f4a f4b
      AddType video/ogg                           ogv
      AddType video/mp4                           mp4 m4v f4v f4p
      AddType video/webm                          webm
      AddType video/x-flv                         flv
      AddType image/svg+xml                       svg svgz
      AddEncoding gzip                            svgz
      AddType application/vnd.ms-fontobject       eot
      AddType application/x-font-ttf              ttf ttc
      AddType font/opentype                       otf
      AddType application/x-font-woff             woff woff2
      AddType image/x-icon                        ico
      AddType image/webp                          webp
      AddType text/cache-manifest                 appcache manifest
      AddType text/x-component                    htc
      AddType application/xml                     rss atom xml rdf
      AddType application/x-web-app-manifest+json webapp
      AddType text/x-vcard                        vcf
      AddType application/x-shockwave-flash       swf
    </IfModule>
    
    ##
    # Gzip compression
    # @see https://github.com/h5bp/html5-boilerplate
    ##
    <IfModule mod_deflate.c>
      <IfModule mod_filter.c>
        AddOutputFilterByType DEFLATE text/html text/plain text/css application/json
        AddOutputFilterByType DEFLATE application/javascript
        AddOutputFilterByType DEFLATE text/xml application/xml text/x-component
        AddOutputFilterByType DEFLATE application/xhtml+xml application/rss+xml application/atom+xml
        AddOutputFilterByType DEFLATE image/x-icon image/svg+xml application/vnd.ms-fontobject application/x-font-ttf font/opentype
      </IfModule>
    </IfModule>
    
    ##
    # Expires headers (for better cache control)
    # @see https://github.com/h5bp/html5-boilerplate
    ##
    <IfModule mod_expires.c>
      ExpiresActive on
    
      ##
      # Productional website
      ##
      ExpiresByType text/cache-manifest           "access plus 0 seconds"
      ExpiresByType text/html                     "access plus 0 seconds"
      ExpiresByType text/xml                      "access plus 0 seconds"
      ExpiresByType application/xml               "access plus 0 seconds"
      ExpiresByType application/json              "access plus 0 seconds"
      ExpiresByType application/rss+xml           "access plus 1 hour"
      ExpiresByType application/atom+xml          "access plus 1 hour"
      ExpiresByType image/gif                     "access plus 1 month"
      ExpiresByType image/png                     "access plus 1 month"
      ExpiresByType image/jpeg                    "access plus 1 month"
      ExpiresByType image/x-icon                  "access plus 1 month"
      ExpiresByType video/ogg                     "access plus 1 month"
      ExpiresByType audio/ogg                     "access plus 1 month"
      ExpiresByType video/mp4                     "access plus 1 month"
      ExpiresByType video/webm                    "access plus 1 month"
      ExpiresByType text/x-component              "access plus 1 month"
      ExpiresByType application/x-font-ttf        "access plus 1 month"
      ExpiresByType font/opentype                 "access plus 1 month"
      ExpiresByType application/x-font-woff       "access plus 1 month"
      ExpiresByType image/svg+xml                 "access plus 1 month"
      ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
      ExpiresByType text/css                      "access plus 1 year"
      ExpiresByType application/javascript        "access plus 1 year"
    
      ##
      # Disable caching during development
      # @see https://github.com/contao/core/issues/4364
      ##
      #ExpiresByType text/cache-manifest           "access"
      #ExpiresByType text/html                     "access"
      #ExpiresByType text/xml                      "access"
      #ExpiresByType application/xml               "access"
      #ExpiresByType application/json              "access"
      #ExpiresByType application/rss+xml           "access"
      #ExpiresByType application/atom+xml          "access"
      #ExpiresByType image/gif                     "access"
      #ExpiresByType image/png                     "access"
      #ExpiresByType image/jpeg                    "access"
      #ExpiresByType image/x-icon                  "access"
      #ExpiresByType video/ogg                     "access"
      #ExpiresByType audio/ogg                     "access"
      #ExpiresByType video/mp4                     "access"
      #ExpiresByType video/webm                    "access"
      #ExpiresByType text/x-component              "access"
      #ExpiresByType application/x-font-ttf        "access"
      #ExpiresByType font/opentype                 "access"
      #ExpiresByType application/x-font-woff       "access"
      #ExpiresByType image/svg+xml                 "access"
      #ExpiresByType application/vnd.ms-fontobject "access"
      #ExpiresByType text/css                      "access"
      #ExpiresByType application/javascript        "access"
    
    </IfModule>
    
    ##
    # Header adjustments
    ##
    <IfModule mod_headers.c>
    
      ##
      # Disable caching during development
      # @see https://github.com/contao/core/issues/4364
      ##
      #Header unset Cache-Control
      #Header append Cache-Control must-revalidate
    
      ##
      # Do not cache the cron.txt file
      # @see https://github.com/contao/core/issues/5105
      ##
      <FilesMatch "cron\.txt$">
        Header set Cache-Control "no-cache, no-store, must-revalidate, max-age=0, proxy-revalidate, no-transform"
      </FilesMatch>
    
      ##
      # Add a Vary Accept-Encoding header for the compressed resources. If you
      # modify the file types above, make sure to change them here accordingly.
      # @see http://developer.yahoo.com/performance/rules.html#gzip
      #
      # Note: If you are using a case-sensitive file system like HFS+ or ext4, you
      # have to change the <FilesMatch> directive as follows:
      #
      # <FilesMatch "\.(?i:js|css|xml|gz|svgz)$">
      #
      # For more information see: https://github.com/contao/core/issues/4364
      ##
      <FilesMatch "\.(js|css|xml|gz|svgz)$">
        Header append Vary Accept-Encoding
      </FilesMatch>
    
    </IfModule>
    
    ##
    # Disable MultiViews if you are having issues with requests returning the wrong
    # page. Requires AllowOverride Options=All,MultiViews to be set here.
    # @see https://github.com/contao/core/issues/3521
    ##
    #Options -MultiViews
    
    ##
    # URL rewriting
    ##
    <IfModule mod_rewrite.c>
      RewriteEngine On
    
      ##
      # Change the RewriteBase if your Contao installation is in a subdirectoy and
      # the rewrite rules are not working properly. Usage examples:
      #
      #   RewriteBase /contao-3.0.0
      #   RewriteBase /path/to/contao
      #
      # Depending on your server, you might have to remove the line entirely.
      ##
      RewriteBase /
    
      ##
      # Uncomment the following lines to add "www." to the domain:
      #
      #   RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
      #   RewriteRule (.*) http://www.example.com/$1 [R=301,L]
      #
      # Uncomment the following lines to remove "www." from the domain:
      #
      #   RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
      #   RewriteRule (.*) http://example.com/$1 [R=301,L]
      #
      # Make sure to replace "example.com" with your domain name.
      ##
    
      ##
      # If you cannot use mod_deflate, uncomment the following lines to load a
      # compressed .gz version of the aggregated Contao JavaScript and CSS files.
      ##
      #AddEncoding gzip .gz
      #<FilesMatch "\.js\.gz$">
      #  AddType "application/javascript" .gz
      #</FilesMatch>
      #<FilesMatch "\.css\.gz$">
      #  AddType "text/css" .gz
      #</FilesMatch>
      #RewriteCond %{HTTP:Accept-encoding} gzip
      #RewriteCond %{REQUEST_FILENAME} \.(js|css)$
      #RewriteCond %{REQUEST_FILENAME}.gz -f
      #RewriteRule ^(.*)$ $1.gz [QSA,L]
    
      ##
      # By default, Contao adds ".html" to the generated URLs to simulate static
      # HTML documents. If you change the URL suffix in the back end settings, make
      # sure to change it here accordingly!
      #
      #   RewriteRule .*\.html$ index.php [L]   # URL suffix .html
      #   RewriteRule .*\.txt$ index.php [L]    # URL suffix .txt
      #   RewriteRule .*\.json$ index.php [L]   # URL suffix .json
      #
      # If you do not want to use an URL suffix at all, you have to add a third
      # line to prevent URLs that point to folders from being rewritten (see #4031).
      #
          Redirect 301 /index https://domain.de
      
          RewriteCond %{REQUEST_FILENAME} !\.(htm|php|js|css|map|htc|png|gif|jpe?g|ico|xml|csv|txt|swf|flv|mp4|webm|ogv|mp3|ogg|oga|eot|otf|tt[cf]|woff2?|svgz?|pdf|zip|gz)$
          RewriteCond %{REQUEST_FILENAME} !-d
          RewriteCond %{REQUEST_FILENAME} !-f
          RewriteRule .* index.php [L]
      #
      # If you are using mod_cache, it is recommended to use the RewriteRule below,
      # which adds the query string to the internal URL:
      #
      #   RewriteRule (.*\.html)$ index.php/$1 [L]
      #
      # Note that not all environments support mod_rewrite and mod_cache.
      ##
      #RewriteCond %{REQUEST_FILENAME} !\.(htm|php|js|css|map|htc|png|gif|jpe?g|ico|xml|csv|txt|swf|flv|mp4|webm|ogv|mp3|ogg|oga|eot|otf|tt[cf]|woff2?|svgz?|pdf|zip|gz)$
      #RewriteCond %{REQUEST_FILENAME} !-f
      #RewriteRule .*\.html$ index.php [L]
    
      ##
      # The following rules are required if you want to pass the language as first
      # URL parameter (added in Contao 2.11). The first rule rewrites the empty URL
      # to the front end controller, the second one adds a missing trailing slash.
      ##
      RewriteRule ^[a-z]{2}(\-[A-Z]{2})?/$ index.php [L]
      RewriteRule ^([a-z]{2}(\-[A-Z]{2})?)$ $1/ [R=301,L]
    
    </IfModule>

  13. #13
    Community-Moderator
    Wandelndes Contao-Lexikon
    Avatar von Spooky
    Registriert seit
    12.04.2012.
    Ort
    Scotland
    Beiträge
    34.100
    Partner-ID
    10107

    Standard

    Bei mir funktioniert es. Mit
    Code:
    Redirect 301 /index http://example.org
    wird http://example.org/index auf http://example.org umgeleitet. Contao Einstellungen:
    PHP-Code:
    $GLOBALS['TL_CONFIG']['addLanguageToUrl'] = false;
    $GLOBALS['TL_CONFIG']['urlSuffix'] = '';
    $GLOBALS['TL_CONFIG']['folderUrl'] = true

  14. #14
    Contao-Nutzer Avatar von Der Astronaut
    Registriert seit
    20.07.2012.
    Ort
    Weltall
    Beiträge
    241

    Standard

    Zwischenzeitlich hatte ich die Testinstallation auf das Suffix .html umgestellt, htaccess dementsprechend wieder in Auslieferungszustand versetzt und wenn ich

    Code:
    Redirect 301 /index\.html https://domain.de
    dazu schreibe, wird korrekt auf root umgeleitet. Unterseiten funktionieren dann auch. Stelle ich den ganzen Kram dann wieder auf ohne Suffix um, bleibt "index" stur stehen.

    Die localconfig.php hatte ich gemäß deinen Angaben angepasst, aber leider ohne Erfolg. Keine Ahnung, was das Problem ist. Vielleicht die Server-Konfiguration? Ich bin bei All-Inkl.com. Account läuft auf PHP 5.6 (CGI). Ansonsten bin ich echt überfragt

    Danke trotzdem für deine Hilfe Spooky. Wie immer top!

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

    Support Contao

    Standard

    Ich denke, duhast hier ein Reihenfolge-Problem. Die .htaccess wird von diversen Modulen nacheinander gelesen, die jeweils nur bestimmte Sets von Direktiven bearbeiten. Redirect macht, glaube ich, mod_alias, die Rewritecond/RewriteRule - wer hätte es gedacht - mod_rewrite. Nun kommt zumindest bei dir mod_rewrite zuerst dran. /indx ist kein reales Verzeichnis und auch keine reale Datei und hat auch keinen Suffix aus der Liste. Somit wird /index durch die RewriteRule aud die index.php umgeschrieben. Wenn danach mod_alias kommt, gibt es da nichts mehr umzuleiten, der Redirect läuft ins Leere... Redirects und Rewrites zu mischen in einer .htaccess ist also in manchen Fällen problematisch. So wie eben hier. Dass es mit Suffix html oder jedem anderen nicht leeren Suffix klappt, ist auch klar, die RewriteRule schreibt dann nur URLs mit diesem Suffix um, dein /index bleibt also verschont .

    Du solltest also in deinem Fall die Weiterleitung am besten auch mit Rewrite machen.

  16. #16
    Contao-Nutzer Avatar von Der Astronaut
    Registriert seit
    20.07.2012.
    Ort
    Weltall
    Beiträge
    241

    Standard

    Ich hatte die Umleitung ja zuerst mit ReWrite gemacht. Hat aber nicht funktioniert. Das kannst du oben nachlesen.

    Du schreibst, dass /index ja kein reales Verzeichnis bzw. keine reale Datei ist. Da stimme ich dir natürlich zu. Doch warum funktionieren Umleitungen von /news auf root oder /hanswurst auf root und nur /index nicht?

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

    Support Contao

    Standard

    Da bin ich mir nicht sicher, eventuell wegen der Sonderbehandlung für den Alias index. Das wäre aber nicht schüssig, dann sollte es auch ohne Suffix gehen. Deine RewriteRule die "funktioniert", hat eben das Problem, dass auch die index.php umgeschrieben wird, was natürlich unangenehme Folgen für alle anderen URLs hat.

  18. #18
    Contao-Nutzer
    Registriert seit
    13.05.2016.
    Beiträge
    52

    Standard

    Ich würde einfach ein link rel canonical verwenden, dann hast Du kein Problem mit Duplicate Content.

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
  •