Ergebnis 1 bis 10 von 10

Thema: .htaccess mod_rewrite Anzeige ohne www. ist erwünscht - Contao 3.0.3

  1. #1
    Contao-Nutzer
    Registriert seit
    06.03.2014.
    Beiträge
    11

    Standard .htaccess mod_rewrite Anzeige ohne www. ist erwünscht - Contao 3.0.3

    Hallo,

    möchte das die Seite nur ohne www. ausgegeben wird.
    Im Root-Verzeichnis sind Verzeichnisse wie "contao", "files", "share", "system", "templates" etc. vorhanden.

    In der ellenlangen .htaccess-Datei habe ich
    Code:
    ##
      # Uncomment to redirect domains with "www" to the empty domain.
      ##
      RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
      RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
    auskommentiert und trotzdem ist die Seite noch mit www. erreichbar.

    Auch hätte ich anstatt http://www.meineseite.de/index.php/startseite.html
    kein index.php im Pfad http://meineseite.de/startseite.html

    Hier der aktuelle mod_rewrite-Teil:
    Code:
    ##
    # 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 to redirect domains without "www" to the "www" subdomain.
      ##
      #RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
      #RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    
      ##
      # Uncomment to redirect domains with "www" to the empty domain.
      ##
      RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
      RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
     
      
      ##
      # 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 "text/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]
    
      ##
      # Do not rewrite requests for static files or folders such as style sheets,
      # images, movies or text documents. Do not add the URL suffix here!
      #
      # 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:htm|php|js|css| … |gz)$">
      #
      # For more information see: https://github.com/contao/core/issues/4364
      ##
      <FilesMatch "\.(htm|php|js|css|htc|png|gif|jpe?g|ico|xml|csv|txt|swf|flv|eot|woff|svg|ttf|pdf|gz)$">
        RewriteEngine Off
      </FilesMatch>
    
      ##
      # 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 second
      # 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} !-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 an empty URL
      # to the front end controller, the second one adds a missing trailing slash.
      ##
      RewriteRule ^[a-z]{2}/$ index.php [L]
      RewriteRule ^([a-z]{2})$ $1/ [R=301,L]
    
    </IfModule>

    Wer kann helfen?

    Gruß
    Anton
    Geändert von A-0821 (10.03.2014 um 11:12 Uhr)

  2. #2
    Contao-Urgestein
    Registriert seit
    10.07.2010.
    Beiträge
    4.403
    User beschenken
    Wunschliste

    Standard

    .htaccess.default nach .htaccess kopiert hast Du oder?!

    Zitat Zitat von A-0821
    auskommentiert und trotzdem ist die Seite noch mit www. erreichbar.
    Der Trick in der .htaccess ist ja auch nur da dich auf die Seite ohne www zu leiten. Wechselt es auf ohne www. wenn es nun mit www eingibst?

    Wenn kein www. mehr willst, musst Du das mit dem Provider & dessen DNS Server lösen. Der Subdomain Eintrag www müsstes Du da entfernen lassen. Erst dann gibt es kein www. mehr.

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

    Support Contao

    Standard

    Und beim zweiten Problem (index.php) hilft es, in den Einstellungen im Backend (Frontend-Einstellungen) "URLs umschreiben" zu aktivieren.

  4. #4
    Contao-Nutzer
    Registriert seit
    06.03.2014.
    Beiträge
    11

    Standard

    ciaobello

    .htaccess.default nach .htaccess kopiert hast Du oder?!
    Ja.

    Der Trick in der .htaccess ist ja auch nur da dich auf die Seite ohne www zu leiten. Wechselt es auf ohne www. wenn es nun mit www eingibst?
    Wenn ich www.meinedomain.de eingebe, wird auf meinedomain.de "umgeschaltet".
    Wenn ich im Browser manuell www.meinedomain.de/index.php/startseite.html eingebe, wird nicht auf ohne www "umgeschaltet". ???

    Wenn kein www. mehr willst, musst Du das mit dem Provider & dessen DNS Server lösen. Der Subdomain Eintrag www müsstes Du da entfernen lassen. Erst dann gibt es kein www. mehr.
    Sorry, bist Du sicher?
    Habe diese Problematik bisher immer über die .htaccess gelöst. Nur war da bisher noch kein Contao-CMS dabei...
    Obwohl es meines gefährlichen Halbwissens nach, egal sein sollte welches CMS da läuft ?

    Hhmmm...

    Gruß
    Anton

  5. #5
    Contao-Nutzer
    Registriert seit
    06.03.2014.
    Beiträge
    11

    Standard

    Zitat Zitat von tab Beitrag anzeigen
    Und beim zweiten Problem (index.php) hilft es, in den Einstellungen im Backend (Frontend-Einstellungen) "URLs umschreiben" zu aktivieren.
    DAAAANNNKEEE

    Sieht gut aus!

    Gruß
    Anton

  6. #6
    Contao-Nutzer
    Registriert seit
    06.03.2014.
    Beiträge
    11

    Standard

    Nachdem ich den Hinweis von tab umgesetzt habe,
    kann ich auch nicht mehr manuell www.meinedomain.de/startseite.html eingeben
    ohne dann auf meinedomain.de/startseite.html verwiesen zu werden!!!

    Habe es gerade nochmal auch rückwärts getestet.
    URL's umschreiben deaktiviert und manuelle Eingabe von www.meinedomain.de/index.php/startseite.html getätigt,
    Anzeige-Ergebnis = www.meinedomain.de/index.php/startseite.html !!!

    Danke allen Helfenden!!

    Gruß
    Anton

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

    Support Contao

    Standard

    Zitat Zitat von A-0821 Beitrag anzeigen
    Nachdem ich den Hinweis von tab umgesetzt habe,
    kann ich auch nicht mehr manuell www.meinedomain.de/startseite.html eingeben
    ohne dann auf meinedomain.de/startseite.html verwiesen zu werden!!!
    So sollte es sein. Trotzdem kommst du natürlich immer noch auch MIT www immer noch auf deine Seite. Wenn ein Aufruf mit www partout gar nicht mehr möglich sein soll, dann muss entweder die Subdomain weg oder du generierst über die .htaccess keine Weiterleitung nach der URL ohne www, sondern gleich einen Status 404

  8. #8
    Contao-Nutzer
    Registriert seit
    06.03.2014.
    Beiträge
    11

    Standard

    Zitat Zitat von tab Beitrag anzeigen
    So sollte es sein. Trotzdem kommst du natürlich immer noch auch MIT www immer noch auf deine Seite.
    Genau so wollte ich es auch eingerichtet wissen!
    Zitat Zitat von tab Beitrag anzeigen
    Wenn ein Aufruf mit www partout gar nicht mehr möglich sein soll, dann muss entweder die Subdomain weg oder du generierst über die .htaccess keine Weiterleitung nach der URL ohne www, sondern gleich einen Status 404
    Danke für die Wissensvermittlung! Dann traf ja ciaobello's Hinweis den Nagel auf den Kopf
    und mein Kopf hat eine Bildungslücke geschlossen!

    Danke euch nochmal und bin angenehm beeindruckt von der Geschwindigkeit eurer Antworten!

    Gruß
    Anton

  9. #9
    Contao-Nutzer
    Registriert seit
    06.03.2014.
    Beiträge
    11

    Standard

    Hallo,

    oh morgendlicher Schreck - irgendwie begreif ich es wohl nicht.
    In den Google-Suchergebnissen auf ein eigenes Ergebnis geklickt http://www.meineseite.de/index.php/seite2.html
    und einen 404-Fehler erhalten.

    Gebe ich irgendeine URL händisch in den Browser ein, nach "alter Schreibweise" www.meineseite.de/index.php/seitexyz.html
    erhalte ich einen 404-Fehler...
    Aber das war doch gestern - dachte ich, schon mal alles okay???


    Bin sprachlos.
    Code:
    ##
    # 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 to redirect domains without "www" to the "www" subdomain.
      ##
      #RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
      #RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    
      ##
      # Uncomment to redirect domains with "www" to the empty domain.
      ##
      RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
      RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
      
     
      
      ##
      # 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 "text/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]
    
      ##
      # Do not rewrite requests for static files or folders such as style sheets,
      # images, movies or text documents. Do not add the URL suffix here!
      #
      # 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:htm|php|js|css| … |gz)$">
      #
      # For more information see: https://github.com/contao/core/issues/4364
      ##
      <FilesMatch "\.(htm|php|js|css|htc|png|gif|jpe?g|ico|xml|csv|txt|swf|flv|eot|woff|svg|ttf|pdf|gz)$">
        RewriteEngine Off
      </FilesMatch>
    
      ##
      # 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 second
      # 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} !-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 an empty URL
      # to the front end controller, the second one adds a missing trailing slash.
      ##
      RewriteRule ^[a-z]{2}/$ index.php [L]
      RewriteRule ^([a-z]{2})$ $1/ [R=301,L]
    
    </IfModule>
    Sorry, wer weiß Rat?
    Was macht diese Anweisung
    Code:
    RewriteRule ^[a-z]{2}/$ index.php [L]
      RewriteRule ^([a-z]{2})$ $1/ [R=301,L]
    eigentlich?

    Oder muss ich jetzt für jede Einzelseite eine 301 Weiterleitung erstellen?

    Gruß
    Anton
    Geändert von A-0821 (11.03.2014 um 08:38 Uhr)

  10. #10
    Contao-Nutzer
    Registriert seit
    06.03.2014.
    Beiträge
    11

    Standard

    Hallo,

    habe jetzt alle bei Google mit site:meinedomain.de gefundenen Einzelseiten
    per
    Code:
    Redirect 301 /index.php/meineeinzelseitexyz.html http://meinedomain.de/meineeinzelseitexyz.html
    weitergeleitet.

    Puh - jetzt scheint es erstmal zu funktionieren...

    Gruß
    Anton

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
  •