Ergebnis 1 bis 8 von 8

Thema: [gelöst] Multi-Domain Rewrite-Problem

  1. #1
    Contao-Nutzer
    Registriert seit
    29.02.2012.
    Beiträge
    4

    Daumen hoch [gelöst] Multi-Domain Rewrite-Problem

    Im Forum ist zwar schon viel zum Thema Multi-Domain enthalten, aber für mein Problem habe ich keine Lösung gefunden.

    Für die meine Domain domain1.net habe ich ein contao-Installation laufen.

    Zusätzlich habe ich jetzt eine domain2.de im Hosting-Paket aktiviert und auch auf den gleichen Unterordner weitergeleitet.
    Es sind im Backend zwei Seiten angelegt und in den DNS-Einstellungen die Domains hinterlegt.

    Wenn ich Rewrite in der .htaccess deaktiviere komme ich bei Eingabe der Domains zur richtigen Seite.
    Aktiviere ich jedoch Rewrite funktioniert nur noch domain1.net. Bei Aufruf von domain2.de kommt der 403-Fehler Zugriff verweigert.

    Als Basis habe ich die .htaccess.default genommen und Regeln für www angepasst.

    Code:
    AddHandler x-httpd-php5 .php
    
    ##
    # Contao Open Source CMS
    # Copyright (C) 2005-2011 Leo Feyer
    #
    # Formerly known as TYPOlight Open Source CMS.
    #
    # This program is free software: you can redistribute it and/or
    # modify it under the terms of the GNU Lesser General Public
    # License as published by the Free Software Foundation, either
    # version 3 of the License, or (at your option) any later version.
    # 
    # This program is distributed in the hope that it will be useful,
    # but WITHOUT ANY WARRANTY; without even the implied warranty of
    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    # Lesser General Public License for more details.
    # 
    # You should have received a copy of the GNU Lesser General Public
    # License along with this program. If not, please visit the Free
    # Software Foundation website at <http://www.gnu.org/licenses/>.
    #
    # PHP version 5
    # @copyright  Leo Feyer 2005-2011
    # @author     Leo Feyer <http://www.contao.org>
    # @license    LGPL
    ##
    
    <IfModule mod_deflate.c>
    
      ##
      # Use mod_deflate to compress JavaScript, CSS and XML files. Do not add
      # PHP and HTML files, because those have already been compressed by Contao.
      ##
      <FilesMatch "\.(css|js|xml)$">
        SetOutputFilter DEFLATE
      </FilesMatch>
    
    </IfModule>
    
    <IfModule mod_headers.c>
    
      ##
      # Add a Vary Accept-Encoding header for the compressed resources. If you
      # modify the file types above, make sure to change them here accordingly.
      ##
      <FilesMatch "\.(js|css|xml|gz)$">
        Header append Vary Accept-Encoding
      </FilesMatch>
    
    </IfModule>
    
    <IfModule mod_expires.c>
      ExpiresActive On
    
      ##
      # Specify an expiration one week in the future for images, JavaScripts and
      # CSS files (as recommended by Google Page Speed). Edit or remove the lines
      # to set up your own expiration logic.
      ##
      ExpiresByType image/png A604800
      ExpiresByType image/gif A604800
      ExpiresByType image/jpg A604800
      ExpiresByType image/jpeg A604800
      ExpiresByType text/javascript A604800
      ExpiresByType application/x-javascript A604800
      ExpiresByType text/css A604800
    
    </IfModule>
    
    <IfModule mod_rewrite.c>
      RewriteEngine On
    
      ##
      # Set the RewriteBase if your Contao installation is in a subdirectoy and
      # the rewrite rules are not working properly. Usage examples:
      #
      #   RewriteBase /contao-2.9.0
      #   RewriteBase /path/to/contao
      #
      # Uncomment the following line to set the RewriteBase.
      ##
      #RewriteBase /
    
      ##
      # Contao usually does not pass absolute URLs via GET, therefore the
      # following rules block all requests that try to pass a URL or the /etc/
      # directory as parameter (malicious requests).
      ##
      RewriteCond %{REQUEST_URI} (ftp|https?):|/etc/ [NC,OR]
      RewriteCond %{QUERY_STRING} (ftp|https?):|/etc/ [NC]
      RewriteRule .* - [F,L]
    
      ##
      # Uncomment the following lines and replace "domain.com" with your domain
      # name to redirect requests without "www" to the correct domain. 
      ##
      #RewriteCond %{HTTP_HOST} ^domain\.com [NC]
      #RewriteRule (.*) http://www.domain.com/$1 [R=301,L]
    
      RewriteCond %{HTTP_HOST} ^domain1\.net [NC]
      RewriteRule (.*) http://www.domain1.net/$1 [R=301,L]
    
      RewriteCond %{HTTP_HOST} ^domain2\.de [NC]
      RewriteRule (.*) http://www.domain2.de/$1 [R=301,L]
    
      ##
      # Do not rewrite requests for static files or folders such as style sheets,
      # images, movies or text documents.
      ##
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
    
      ##
      # 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 .* index.php [L]          # No URL suffix
      #   RewriteRule .*\.txt$ index.php [L]    # URL suffix .txt
      #
      # 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!
      ##
      RewriteRule .*\.html$ index.php [L]
    
    </IfModule>
    Geändert von mb_mail (19.03.2013 um 10:00 Uhr)

  2. #2
    Contao-Urgestein Avatar von folkfreund
    Registriert seit
    09.04.2010.
    Beiträge
    1.928

    Standard

    Hallo mb_mail,

    willkommen im Forum!

    Versuch es mal, wenn du auch die Zeile
    Code:
    RewriteBase /
    aktivierst (das '#' entfernst).

    Habe ich richtig verstanden, dass du deine Seite in einem Unterordner vom DocumentRoot installiert hast?
    Dann muss es evtl. auch
    Code:
    RewriteBase Unterverzeichnis/
    heißen.

    Gruß, folkfreund

  3. #3
    Contao-Nutzer
    Registriert seit
    29.02.2012.
    Beiträge
    4

    Standard

    Die Domains werden direkt auf den contao-Ordner verlinkt, so dass RewriteBase dem root-Ordner entspricht. Aber unabhängig davon, ob RewriteBase auskommentiert ist nicht, funktioniert nur domain1.net

  4. #4
    Contao-Urgestein Avatar von folkfreund
    Registriert seit
    09.04.2010.
    Beiträge
    1.928

    Standard

    Code:
    RewriteBase /
    kann auch notwendig sein, wenn dein Provider die Aufschaltung verschiedener Domains auf denselben Platz ebenfalls per RewriteRule realisiert.

    Dann könntest du noch probieren, die beiden Regeln mal zu tauschen:
    Code:
    RewriteCond %{HTTP_HOST} ^domain2\.de [NC]
    RewriteRule (.*) http://www.domain2.de/$1 [R=301,L]
    
    RewriteCond %{HTTP_HOST} ^domain1\.net [NC]
    RewriteRule (.*) http://www.domain1.net/$1 [R=301,L]
    Kommst du dann nur noch mit www.domain2.de an die Seite?

    Wenn das so ist, dann muss wohl die .htaccess-Doku mal genauer studiert werden. Mit den Rules kenn ich mich auch nicht wirklich aus.

    Ach ja, bei mir ist auch folgendes aktiviert:
    Code:
      # 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]
    Gruß, folkfreund

  5. #5
    Contao-Nutzer
    Registriert seit
    29.02.2012.
    Beiträge
    4

    Standard

    Also wie schon gesagt macht es keinen Unterschied ob RewriteBase aktiv ist oder nicht (und damit meine ich, dass ich das getestet habe) Auch hatte ich bereits die beiden Domains bereits getauscht, leider ohne Wirkung.

    Ach ja, bei mir ist auch folgendes aktiviert:
    Code:
      # 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]
    Dieser Eintrag bringt leider auch keine Änderung.

  6. #6
    Contao-Nutzer
    Registriert seit
    17.07.2010.
    Beiträge
    127

    Standard

    Ich habe genau das gleiche Problem und komme nicht mehr weiter. Wurde das mittlerweile gelöst?

    Es macht keinen Unterschied welche mod_rewrite-Regel ich tausche/deaktiviere/ändere, sobald ich mod_rewrite mit
    Code:
    RewriteEngine On
    aktiviere tritt das Problem auf.
    Ohne mod_rewrite (keine Alternative) tritt das Problem nicht auf.

  7. #7
    Contao-Nutzer
    Registriert seit
    29.02.2012.
    Beiträge
    4

    Standard

    Ja, Funktioniert alles.

    Hier meine .htaccess
    Code:
    #AddHandler x-httpd-php5 .php
    AddHandler x-httpd-php53 .php
    
    ##
    # Contao Open Source CMS
    # Copyright (C) 2005-2011 Leo Feyer
    #
    # Formerly known as TYPOlight Open Source CMS.
    #
    # This program is free software: you can redistribute it and/or
    # modify it under the terms of the GNU Lesser General Public
    # License as published by the Free Software Foundation, either
    # version 3 of the License, or (at your option) any later version.
    # 
    # This program is distributed in the hope that it will be useful,
    # but WITHOUT ANY WARRANTY; without even the implied warranty of
    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    # Lesser General Public License for more details.
    # 
    # You should have received a copy of the GNU Lesser General Public
    # License along with this program. If not, please visit the Free
    # Software Foundation website at <http://www.gnu.org/licenses/>.
    #
    # PHP version 5
    # @copyright  Leo Feyer 2005-2011
    # @author     Leo Feyer <http://www.contao.org>
    # @license    LGPL
    ##
    
    <IfModule mod_deflate.c>
    
      ##
      # Use mod_deflate to compress JavaScript, CSS and XML files. Do not add
      # PHP and HTML files, because those have already been compressed by Contao.
      ##
      <FilesMatch "\.(css|js|xml)$">
        SetOutputFilter DEFLATE
      </FilesMatch>
    
    </IfModule>
    
    <IfModule mod_headers.c>
    
      ##
      # Add a Vary Accept-Encoding header for the compressed resources. If you
      # modify the file types above, make sure to change them here accordingly.
      ##
      <FilesMatch "\.(js|css|xml|gz)$">
        Header append Vary Accept-Encoding
      </FilesMatch>
    
    </IfModule>
    
    <IfModule mod_expires.c>
      ExpiresActive On
    
      ##
      # Specify an expiration one week in the future for images, JavaScripts and
      # CSS files (as recommended by Google Page Speed). Edit or remove the lines
      # to set up your own expiration logic.
      ##
      ExpiresByType image/png A604800
      ExpiresByType image/gif A604800
      ExpiresByType image/jpg A604800
      ExpiresByType image/jpeg A604800
      ExpiresByType text/javascript A604800
      ExpiresByType application/x-javascript A604800
      ExpiresByType text/css A604800
    
    </IfModule>
    
    <IfModule mod_rewrite.c>
      RewriteEngine On
    
      ##
      # Set the RewriteBase if your Contao installation is in a subdirectoy and
      # the rewrite rules are not working properly. Usage examples:
      #
      #   RewriteBase /contao-2.9.0
      #   RewriteBase /path/to/contao
      #
      # Uncomment the following line to set the RewriteBase.
      ##
      RewriteBase /
    
      ##
      # Contao usually does not pass absolute URLs via GET, therefore the
      # following rules block all requests that try to pass a URL or the /etc/
      # directory as parameter (malicious requests).
      ##
      RewriteCond %{REQUEST_URI} (ftp|https?):|/etc/ [NC,OR]
      RewriteCond %{QUERY_STRING} (ftp|https?):|/etc/ [NC]
      RewriteRule .* - [F,L]
    
      ##
      # Uncomment the following lines and replace "domain.com" with your domain
      # name to redirect requests without "www" to the correct domain. 
      ##
      #RewriteCond %{HTTP_HOST} ^domain\.com [NC]
      #RewriteRule (.*) http://www.domain.com/$1 [R=301,L]
    
      RewriteCond %{HTTP_HOST} ^domain2\.de [NC]
      RewriteRule (.*) http://www.domain2.de/$1 [R=301,L]
      RewriteCond %{HTTP_HOST} ^domain1\.net [NC]
      RewriteRule (.*) http://www.domain1.net/$1 [R=301,L]
    
      ##
      # Do not rewrite requests for static files or folders such as style sheets,
      # images, movies or text documents.
      ##
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
    
      ##
      # 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 .* index.php [L]          # No URL suffix
      #   RewriteRule .*\.txt$ index.php [L]    # URL suffix .txt
      #
      # 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!
      ##
      #RewriteRule .*\.html$ index.php [L]
      RewriteRule (.*\.html)$ index.php/$1 [L]
    
    </IfModule>

  8. #8
    Contao-Nutzer
    Registriert seit
    17.07.2010.
    Beiträge
    127

    Standard

    Danke für die Antwort mb_mail.

    Wie sich herausgestellt hat, musste mein Provider Hoststar mod_rewrite auf der zweiten Domain erst aktivieren.
    Klappt nun aber sogar ohne .htaccess Änderung (d.h. default .htaccess von Contao).

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
  •