Ergebnis 1 bis 4 von 4

Thema: mod_rewrite Regeln greifen nicht immer

  1. #1
    AG Pressearbeit
    Community-Moderator
    Buchautor 'Contao für Webdesigner'
    Avatar von planepix
    Registriert seit
    05.06.2009.
    Ort
    Stuttgart
    Beiträge
    6.469
    Partner-ID
    107
    Contao-Projekt unterstützen

    Support Contao

    Standard mod_rewrite Regeln greifen nicht immer

    Ahoi in die Runde,

    ich habe Umleitungsregeln in der .htaccess (im Verzeichnis web) erstellt.

    URL alte Domain auf neue Domain:
    Code:
    1. Redirect 301 /index.php/produkte https://domain.tld/produkte.html
    2. Redirect 301 /index.php/produkte/produkte-neu https://domain.tld/produkte/neue-produkte.html
    Zeile 1 klappt, Zeile 2 nicht. Any Ideas?

    Gebe ich die alte URL ein lande ich nicht auf der neuen Ziel-URL, sondern diese wird so ausgegeben:
    Code:
    https://domain.tld/produkte/neue-produkte.html/produkte-neu
    Geändert von planepix (07.03.2018 um 17:35 Uhr)
    ---------------------------------
    Beste Grüße planepix
    Contao für Webdesigner (Website), Twitter: @contaowebdesign
    weitzeldesign
    Contao-Sprechstunde
    Contao Schulungen: https://www.weitzeldesign.com/cms-co...chulungen.html
    Contao Jahrbuch: www.contao-jahrbuch.de
    Contao Agenturtag: www.contao-agenturtag.de
    Contao Stammtisch Stuttgart: www.contao-stammtisch-stuttgart.de
    Contao 4 Erfahrungen als Gitbook: https://app.gitbook.com/@planepix/s/...-mit-contao-4/
    Contao 4 & Manager Hosterhinweise: https://github.com/contao/contao-manager/wiki

    Schon wieder ein Update?
    Glücklich sind die, die den Wert erkennen – und wertschätzen.
    „Muss man machen wie beim Zahnarzt. Der bestraft einen auch mit hohen Rechnungen wenn man die Pflege vernachlässigt.”

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

    Standard

    /index.php/produkte/produkte-neu leitet vermutlich auf https://domain.tld/produkte.html weiter, oder? Verwende lieber
    Code:
    RedirectMatch 301 ^/index.php/produkte$ https://domain.tld/produkte.html
    RedirectMatch 301 ^/index.php/produkte/produkte-neu$ https://domain.tld/produkte/neue-produkte.html

  3. #3
    AG Pressearbeit
    Community-Moderator
    Buchautor 'Contao für Webdesigner'
    Avatar von planepix
    Registriert seit
    05.06.2009.
    Ort
    Stuttgart
    Beiträge
    6.469
    Partner-ID
    107
    Contao-Projekt unterstützen

    Support Contao

    Standard

    Danke Spooky.

    Ändert sich nichts gegenüber vorher.

    Eingestellt ist die Option „Ordner-URLs” zu verwenden.

    Die Weiterleitungen sind manchmal auf domain.tld/seite.html, manchmal auch auf domain.tld/seite/unterseite.html.
    Sobald die alte URL auch auf dem URL-Fragment /seite/unterseite besteht, wird nicht mehr richtig weitergeleitet.

    Code:
    RedirectMatch 301 ^/index.php/produkt/produkt-neu  http://domain.com/produkt/tolles-produkt.html
    wird nach dem Aufruf zu
    Code:
    https://www.domain.com/produkt.html/produkt-neu
    Sprich die Unterseite, die als Ziel angegeben ist, wird gar nicht berücksichtigt.

    Inhalt der .htaccess:

    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
        
        # Umleitung auf SSL
          RewriteCond %{HTTP_HOST} ^domain\.com [NC]
          RewriteRule (.*) https://www.domain.com/$1 [R=301,L]
    
        # Redirects
           RedirectMatch 301 ^/index.php/produkte/neue-produkte$ https://www.domain.com/produkte/uebersicht.html
    
        # 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}]
    
        # 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>
    Geändert von planepix (07.03.2018 um 18:18 Uhr)
    ---------------------------------
    Beste Grüße planepix
    Contao für Webdesigner (Website), Twitter: @contaowebdesign
    weitzeldesign
    Contao-Sprechstunde
    Contao Schulungen: https://www.weitzeldesign.com/cms-co...chulungen.html
    Contao Jahrbuch: www.contao-jahrbuch.de
    Contao Agenturtag: www.contao-agenturtag.de
    Contao Stammtisch Stuttgart: www.contao-stammtisch-stuttgart.de
    Contao 4 Erfahrungen als Gitbook: https://app.gitbook.com/@planepix/s/...-mit-contao-4/
    Contao 4 & Manager Hosterhinweise: https://github.com/contao/contao-manager/wiki

    Schon wieder ein Update?
    Glücklich sind die, die den Wert erkennen – und wertschätzen.
    „Muss man machen wie beim Zahnarzt. Der bestraft einen auch mit hohen Rechnungen wenn man die Pflege vernachlässigt.”

  4. #4
    Contao-Fan Avatar von Fachinger
    Registriert seit
    24.04.2016.
    Ort
    Limburg
    Beiträge
    308

    Standard

    Vertausch mal die Reihenfolge der Regeln, vielleicht greifen die falsch.


    Gesendet von meinem LG-H815 mit Tapatalk
    Geändert von xchs (08.03.2018 um 08:32 Uhr)

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
  •