Ergebnis 1 bis 12 von 12

Thema: Sprach- Weiterleitungen?

  1. #1
    Contao-Fan
    Registriert seit
    13.12.2012.
    Beiträge
    621

    Standard Sprach- Weiterleitungen?

    Hi,

    ich habe eine .com Domain, diese möchte ich jetzt auf eine andere Domain weiterleiten, jedoch, wenn der browser deutsch ist, auf eine .de und wenn er englisch ist, auf eine .com, diese wäre auch ein fallback.
    Wie kann ich das in Contao machen?

    LG & Danke

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

    Standard

    Wenn du das so machst und dem Benutzer auch keine Chance gibst, dies zu umgehen, dann kann ein Benutzer, der seinen Browser auf Englisch eingestellt hat, die Deutsche Seite gar nicht benutzen.

    Du solltest vielleicht eher überlegen, ob du stattdessen nicht eine einmalige Landing Page oder Overlay für so einen Fall anzeigen lässt, wo du dem Benutzer darauf hinweist, dass es die Website auf einer anderen Domain auch in einer anderen Sprache gibt - falls das überhaupt notwendig ist.

  3. #3
    Contao-Fan
    Registriert seit
    13.12.2012.
    Beiträge
    621

    Standard

    Zitat Zitat von Spooky Beitrag anzeigen
    Wenn du das so machst und dem Benutzer auch keine Chance gibst, dies zu umgehen, dann kann ein Benutzer, der seinen Browser auf Englisch eingestellt hat, die Deutsche Seite gar nicht benutzen.

    Du solltest vielleicht eher überlegen, ob du stattdessen nicht eine einmalige Landing Page oder Overlay für so einen Fall anzeigen lässt, wo du dem Benutzer darauf hinweist, dass es die Website auf einer anderen Domain auch in einer anderen Sprache gibt - falls das überhaupt notwendig ist.
    Ich weis was du meinst aber so sind nun mal die vorgaben, hätte es auch lieber mit eienr art Auswahl gemacht.

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

    Standard

    Du kannst ja aufgrund deiner Expertise Feedback zu diesen Vorgaben liefern .

    Eine solche Weiterleitung könntest du sogar pur im Apache machen (in der .htaccess). Mit RewriteConds auf die Domain, User Agent und Accept Language. Vorsicht: egal wie du es umsetzt, du musst darauf achten, dass du die wichtigsten Bots (Facebook, Google und alle sonstigen Suchmaschinen) von dieser Umleitung ausschließt.
    Geändert von Spooky (28.03.2018 um 14:03 Uhr)

  5. #5
    Contao-Fan
    Registriert seit
    13.12.2012.
    Beiträge
    621

    Standard

    Zitat Zitat von Spooky Beitrag anzeigen
    Du kannst ja aufgrund deiner Expertise Feedback zu diesen Vorgaben liefern .

    Eine solche Weiterleitung könntest du sogar pur im Apache machen (in der .htaccess). Mit RewriteConds auf die Domain und den User Agent. Vorsicht: egal wie du es umsetzt, du musst darauf achten, dass du die wichtigsten Bots (Facebook, Google und alle sonstigen Suchmaschinen) von dieser Umleitung ausschließt.
    Ich kann Sowas auch in der .htaccess machen? auch mit dem User Agent?

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

    Standard

    Ja, zB:
    Code:
    RewriteCond %{HTTP_HOST} ^example\.de$ [NC]
    RewriteCond %{HTTP:Accept-Language} ^en(-|$) [NC]
    RewriteCond %{HTTP_USER_AGENT} !^(facebookexternalhit|google) [NC]
    RewriteRule ^ https://example.com%{REQUEST_URI} [R=301,L]
    Das sollte User mit englischem Browser von example.de auf example.com weiterleiten, außer den google und Facebook Bot. (ungetestet)
    Geändert von Spooky (28.03.2018 um 14:49 Uhr)

  7. #7
    Contao-Fan
    Registriert seit
    13.12.2012.
    Beiträge
    621

    Standard

    Funktioniert, nur ein kleiner Fehler ich leiter weiter auf domain.com/test und er setzt hinter das test immer ein "/" und dann wird die Seite nicht gefunden.

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

    Standard

    Poste deine .htaccess

  9. #9
    Contao-Fan
    Registriert seit
    13.12.2012.
    Beiträge
    621

    Standard

    Code:
    <IfModule mod_deflate.c>
    	# Force compression for mangled `Accept-Encoding` request headers
    	<IfModule mod_setenvif.c>
    		<IfModule mod_headers.c>
    			SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
    			RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
    		</IfModule>
    	</IfModule>
    
    	# Compress all output labeled with one of the following media types.
    	#
    	# (!) For Apache versions below version 2.3.7 you don't need to
    	# enable `mod_filter` and can remove the `<IfModule mod_filter.c>`
    	# and `</IfModule>` lines as `AddOutputFilterByType` is still in
    	# the core directives.
    	#
    	# https://httpd.apache.org/docs/current/mod/mod_filter.html#addoutputfilterbytype
    
    	<IfModule mod_filter.c>
    		AddOutputFilterByType DEFLATE application/atom+xml \
    			application/javascript \
    			application/json \
    			application/ld+json \
    			application/manifest+json \
    			application/rdf+xml \
    			application/rss+xml \
    			application/schema+json \
    			application/vnd.geo+json \
    			application/vnd.ms-fontobject \
    			application/x-font-ttf \
    			application/x-javascript \
    			application/x-web-app-manifest+json \
    			application/xhtml+xml \
    			application/xml \
    			font/eot \
    			font/opentype \
    			image/bmp \
    			image/svg+xml \
    			image/vnd.microsoft.icon \
    			image/x-icon \
    			text/cache-manifest \
    			text/css \
    			text/html \
    			text/javascript \
    			text/plain \
    			text/vcard \
    			text/vnd.rim.location.xloc \
    			text/vtt \
    			text/x-component \
    			text/x-cross-domain-policy \
    			text/xml
    	</IfModule>
    
    	<IfModule mod_mime.c>
    		AddEncoding gzip              svgz
    	</IfModule>
    </IfModule>
    
    ### End: Compression ###
    
    
    
    ### Begin: Browser caching of resource files ###
    
    # This affects Frontend and Backend and increases performance.
    <IfModule mod_expires.c>
    
    	ExpiresActive on
    	ExpiresDefault                                      "access plus 1 month"
    
    	ExpiresByType text/css                              "access plus 1 year"
    
    	ExpiresByType application/json                      "access plus 0 seconds"
    	ExpiresByType application/ld+json                   "access plus 0 seconds"
    	ExpiresByType application/schema+json               "access plus 0 seconds"
    	ExpiresByType application/vnd.geo+json              "access plus 0 seconds"
    	ExpiresByType application/xml                       "access plus 0 seconds"
    	ExpiresByType text/xml                              "access plus 0 seconds"
    
    	ExpiresByType image/vnd.microsoft.icon              "access plus 1 week"
    	ExpiresByType image/x-icon                          "access plus 1 week"
    
    	ExpiresByType text/x-component                      "access plus 1 month"
    
    	ExpiresByType text/html                             "access plus 0 seconds"
    
    	ExpiresByType application/javascript                "access plus 1 year"
    	ExpiresByType application/x-javascript              "access plus 1 year"
    	ExpiresByType text/javascript                       "access plus 1 year"
    
    	ExpiresByType application/manifest+json             "access plus 1 week"
    	ExpiresByType application/x-web-app-manifest+json   "access plus 0 seconds"
    	ExpiresByType text/cache-manifest                   "access plus 0 seconds"
    
    	ExpiresByType audio/ogg                             "access plus 1 month"
    	ExpiresByType image/bmp                             "access plus 1 month"
    	ExpiresByType image/gif                             "access plus 1 month"
    	ExpiresByType image/jpeg                            "access plus 1 month"
    	ExpiresByType image/jpg                             "access plus 1 month"
    	ExpiresByType image/png                             "access plus 1 month"
    	ExpiresByType image/svg+xml                         "access plus 1 month"
    	ExpiresByType image/webp                            "access plus 1 month"
    	ExpiresByType video/mp4                             "access plus 1 month"
    	ExpiresByType video/ogg                             "access plus 1 month"
    	ExpiresByType video/webm                            "access plus 1 month"
    
    	ExpiresByType application/atom+xml                  "access plus 1 hour"
    	ExpiresByType application/rdf+xml                   "access plus 1 hour"
    	ExpiresByType application/rss+xml                   "access plus 1 hour"
    
    	ExpiresByType application/vnd.ms-fontobject         "access plus 1 month"
    	ExpiresByType font/eot                              "access plus 1 month"
    	ExpiresByType font/opentype                         "access plus 1 month"
    	ExpiresByType application/x-font-ttf                "access plus 1 month"
    	ExpiresByType application/font-woff                 "access plus 1 month"
    	ExpiresByType application/x-font-woff               "access plus 1 month"
    	ExpiresByType font/woff                             "access plus 1 month"
    	ExpiresByType application/font-woff2                "access plus 1 month"
    
    	ExpiresByType text/x-cross-domain-policy            "access plus 1 week"
    
    </IfModule>
    
    ### End: Browser caching of resource files ###
    
    
    ### Begin: MIME types ###
    
    # Proper MIME types for all files
    <IfModule mod_mime.c>
    
    	# Data interchange
    	AddType application/atom+xml                        atom
    	AddType application/json                            json map topojson
    	AddType application/ld+json                         jsonld
    	AddType application/rss+xml                         rss
    	AddType application/vnd.geo+json                    geojson
    	AddType application/xml                             rdf xml
    
    	# JavaScript
    	AddType application/javascript                      js
    
    	# Manifest files
    	AddType application/manifest+json                   webmanifest
    	AddType application/x-web-app-manifest+json         webapp
    	AddType text/cache-manifest                         appcache
    
    	# Media files
    
    	AddType audio/mp4                                   f4a f4b m4a
    	AddType audio/ogg                                   oga ogg opus
    	AddType image/bmp                                   bmp
    	AddType image/svg+xml                               svg svgz
    	AddType image/webp                                  webp
    	AddType video/mp4                                   f4v f4p m4v mp4
    	AddType video/ogg                                   ogv
    	AddType video/webm                                  webm
    	AddType video/x-flv                                 flv
    	AddType image/x-icon                                cur ico
    
    	# Web fonts
    	AddType application/font-woff                       woff
    	AddType application/font-woff2                      woff2
    	AddType application/vnd.ms-fontobject               eot
    	AddType application/x-font-ttf                      ttc ttf
    	AddType font/opentype                               otf
    
    	# Other
    	AddType application/octet-stream                    safariextz
    	AddType application/x-bb-appworld                   bbaw
    	AddType application/x-chrome-extension              crx
    	AddType application/x-opera-extension               oex
    	AddType application/x-xpinstall                     xpi
    	AddType text/vcard                                  vcard vcf
    	AddType text/vnd.rim.location.xloc                  xloc
    	AddType text/vtt                                    vtt
    	AddType text/x-component                            htc
    
    </IfModule>
    
    <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}]
    
        # 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]
    
      # Adaptive-Images -----------------------------------------------------------------------------------
    
      # Add any directories you wish to omit from the Adaptive-Images process on a new line, as follows:
      # RewriteCond %{REQUEST_URI} !ignore-this-directory
      # RewriteCond %{REQUEST_URI} !and-ignore-this-directory-too
    
      # don't apply the AI behaviour to images inside AI's cache folder:
      RewriteCond %{REQUEST_URI} !ai-cache
    
      # Send any GIF, JPG, or PNG request that IS NOT stored inside one of the above directories
      # to adaptive-images.php so we can select appropriately sized versions
    
      RewriteRule \.(?:jpe?g|gif|png)$ ai.php [L]
    
      
    RewriteCond %{HTTP_HOST} ^www\.intra\.com$ [NC]
    RewriteCond %{HTTP:Accept-Language} ^en(-|$) [NC]
    RewriteCond %{HTTP_USER_AGENT} !^(facebookexternalhit|google) [NC]
    RewriteRule ^ https://www.instra2.com/welcome%{REQUEST_URI} [R=301,L]
    
    RewriteCond %{HTTP_HOST} ^www\.intra\.com$ [NC]
    RewriteCond %{HTTP:Accept-Language} ^de(-|$) [NC]
    RewriteCond %{HTTP_USER_AGENT} !^(facebookexternalhit|google) [NC]
    RewriteRule ^ https://www.intra2.de/willkommen%{REQUEST_URI} [R=301,L]
    
    
    # END Adaptive-Images -------------------------------------------------------------------------------
    # Adds www. to URLs without
    ##
    
    
    
    
    
    ##
    # Domain redirects
    ##
    
    
    
    
    
    #------------------------------------------------------------------------Pages redirect-----------------------
    
    
    
    
    
    
        # 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>

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

    Standard

    Deine Redirects solltest du direkt nach RewriteEngine On hingeben.

  11. #11
    Contao-Fan
    Registriert seit
    13.12.2012.
    Beiträge
    621

    Standard

    Aber auch da ist es so.

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

    Standard

    Code:
    RewriteRule ^ https://www.instra2.com/welcome%{REQUEST_URI} [R=301,L]
    solltest du außerdem auf
    Code:
    RewriteRule ^ https://www.instra2.com/welcome [R=301,L]
    ändern, denn sonst führt die Eingabe von https://www.instra2.de/foo auf https://www.instra2.com/welcome/foo

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
  •