Deine eigenen Redirets über die RewriteEngine musst du direkt nach RewriteEngine On geben, ansonsten werden die regulären Rewrites von Contao bzw. Symfony vorher ausgeführt.
Deine eigenen Redirets über die RewriteEngine musst du direkt nach RewriteEngine On geben, ansonsten werden die regulären Rewrites von Contao bzw. Symfony vorher ausgeführt.
Also ich habe den code jetzt direkt unter:
Es funktioniert lieder immer noch nicht.Code:RewriteEngine On
Wenn ich jetzt diese Bereich entferne:
Dann funktioniert es für die deutsche Seite, nur eben nicht für die englische aber die Seite ist wieder erreichbar.Code:RewriteCond %{HTTP_HOST} domain\.com$ [NC] RewriteRule ^(.*)$ http://dev.domain.com/en/$1 [R=301,L]
Poste wieder deine .htaccess
Problem ist jetzt: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 # Add language code ------------------------------------------------------------------------------- RewriteCond %{HTTP_HOST} domain\.de$ [NC] RewriteRule ^(.*)$ http://dev.domain.com/de/$1 [R=301,L] RewriteCond %{HTTP_HOST} domain\.nl$ [NC] RewriteRule ^(.*)$ http://dev.domain.com/nl/$1 [R=301,L] RewriteCond %{HTTP_HOST} domain\.fr$ [NC] RewriteRule ^(.*)$ http://dev.domain.com/fr/$1 [R=301,L] # 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] # END Adaptive-Images ------------------------------------------------------------------------------- # Adds www. to URLs without ## RewriteCond %{HTTP_HOST} ^domain\.de [NC] RewriteRule (.*) https://www.domain.de/$1 [R=301,L] RewriteCond %{HTTP_HOST} ^domain\.com [NC] RewriteRule (.*) https://www.domain.com/$1 [R=301,L] RewriteCond %{HTTP_HOST} ^domain\.fr [NC] RewriteRule (.*) https://www.domain.fr/$1 [R=301,L] RewriteCond %{HTTP_HOST} ^domain\.nl [NC] RewriteRule (.*) https://www.domain.nl/$1 [R=301,L] RewriteCond %{HTTP_HOST} ^(www.)?domain.com/de/$ RewriteRule sitemap.xml share/domainde.xml [L] RewriteCond %{HTTP_HOST} ^(www.)?domain.com/en/$ RewriteRule sitemap.xml share/domaincom.xml [L] RewriteCond %{HTTP_HOST} ^(www.)?domain.com/fr/$ RewriteRule sitemap.xml share/domainfr.xml [L] RewriteCond %{HTTP_HOST} ^(www.)?domain.com/nl/$ RewriteRule sitemap.xml share/domainnl.xml [L] ## # Domain redirects ## RewriteCond %{SERVER_NAME} ^www\.domain-systems\.de$ [NC] RewriteRule ^ http://www.domain.de/ [L,R=301] RewriteCond %{SERVER_NAME} ^www\.domainsoftware\.de$ [NC] RewriteRule ^ http://www.domain.de/ [L,R=301] RewriteCond %{SERVER_NAME} ^www\.domain-online\.de$ [NC] RewriteRule ^ http://www.domain.de/ [L,R=301] RewriteCond %{SERVER_NAME} ^www\.domain.at RewriteRule ^ http://www.domain.de/ [L,R=301] RewriteCond %{SERVER_NAME} ^www\.domain24\.com$ [NC] RewriteRule ^ http://www.domain.com/ [L,R=301] RewriteCond %{SERVER_NAME} ^www\.domain24\.net RewriteRule ^ http://www.domain.com/ [L,R=301] RewriteCond %{SERVER_NAME} ^www\.domain\.info$ [NC] RewriteRule ^ http://www.domain.com/ [L,R=301] RewriteCond %{SERVER_NAME} ^www\.domain-online\.net$ [NC] RewriteRule ^ http://www.domain.com/ [L,R=301] RewriteCond %{SERVER_NAME} ^www\.domain\.eu$ [NC] RewriteRule ^ http://www.domain.com/ [L,R=301] RewriteCond %{SERVER_NAME} ^www\.domain\.dk$ [NC] RewriteRule ^ http://www.domain.com/ [L,R=301] RewriteCond %{SERVER_NAME} ^www\.domain\.ag$ [NC] RewriteRule ^ http://www.domain.com/ [L,R=301] RewriteCond %{SERVER_NAME} ^www\.domain\.se$ [NC] RewriteRule ^ http://www.domain.com/ [L,R=301] #------------------------------------------------------------------------Pages redirect----------------------- #ENGLISH #FRANZÖSISCH # 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>
dev.domain.de/loesungen leitet weiter auf dev.domain.com/de/loesungen, was ja passt.
dev.domain.com/solutions leitet aber weiter auf dev.domain.com/de/solutions, was eine 404 ausgibt, richtig wäre ja dev.domain.com/en/solutions.
Du hast immer noch Redirects über die RewriteEngine, die nicht direkt nach RewriteEngine On kommen. Darüberhinaus würde ich dir raten, die .htaccess mal aufzuräumen und korrekte Einrückungen zu benutzen, ansonsten hast du ja keinen Überblick mehr.
Aber die sind doch direkt drunter:
Bildschirmfoto 2019-05-06 um 10.19.28.png
Ja, aber du hast ja noch viel, viel mehr.
Aber in der Contao .htaccess steht doch auch sehr viel mehr, weiter oben.
Also soll ich jetzt den kompletten Bereich:
Nach oben ziehen?Code:<IfModule mod_rewrite.c> RewriteEngine On
Nein, nein. Du musst alle deine eigenen Redirects, die du mit der RewriteEngine machst, direkt nach RewriteEngine On geben. Also vor den RewriteRules für Symfony.
Du meinst so?
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 # Add language code ------------------------------------------------------------------------------- RewriteCond %{HTTP_HOST} intershop\.de$ [NC] RewriteRule ^(.*)$ http://dev.domain.com/de/$1 [R=301,L] RewriteCond %{HTTP_HOST} intershop\.nl$ [NC] RewriteRule ^(.*)$ http://dev.intershop.com/nl/$1 [R=301,L] RewriteCond %{HTTP_HOST} intershop\.fr$ [NC] RewriteRule ^(.*)$ http://dev.intershop.com/fr/$1 [R=301,L] # Adds www. to URLs without ## RewriteCond %{HTTP_HOST} ^domain\.de [NC] RewriteRule (.*) https://www.domain.de/$1 [R=301,L] RewriteCond %{HTTP_HOST} ^domain\.com [NC] RewriteRule (.*) https://www.domain.com/$1 [R=301,L] RewriteCond %{HTTP_HOST} ^domain\.fr [NC] RewriteRule (.*) https://www.domain.fr/$1 [R=301,L] RewriteCond %{HTTP_HOST} ^domain\.nl [NC] RewriteRule (.*) https://www.domain.nl/$1 [R=301,L] RewriteCond %{HTTP_HOST} ^(www.)?domain.com/de/$ RewriteRule sitemap.xml share/domainde.xml [L] RewriteCond %{HTTP_HOST} ^(www.)?domain.com/en/$ RewriteRule sitemap.xml share/domaincom.xml [L] RewriteCond %{HTTP_HOST} ^(www.)?domain.com/fr/$ RewriteRule sitemap.xml share/domainfr.xml [L] RewriteCond %{HTTP_HOST} ^(www.)?domain.com/nl/$ RewriteRule sitemap.xml share/domainnl.xml [L] ## # Domain redirects ## RewriteCond %{SERVER_NAME} ^www\.domain-systems\.de$ [NC] RewriteRule ^ http://www.domain.de/ [L,R=301] RewriteCond %{SERVER_NAME} ^www\.domainsoftware\.de$ [NC] RewriteRule ^ http://www.domain.de/ [L,R=301] RewriteCond %{SERVER_NAME} ^www\.domain-online\.de$ [NC] RewriteRule ^ http://www.domain.de/ [L,R=301] RewriteCond %{SERVER_NAME} ^www\.domain.at RewriteRule ^ http://www.domain.de/ [L,R=301] RewriteCond %{SERVER_NAME} ^www\.domain24\.com$ [NC] RewriteRule ^ http://www.domain.com/ [L,R=301] RewriteCond %{SERVER_NAME} ^www\.domain24\.net RewriteRule ^ http://www.domain.com/ [L,R=301] RewriteCond %{SERVER_NAME} ^www\.domain\.info$ [NC] RewriteRule ^ http://www.domain.com/ [L,R=301] RewriteCond %{SERVER_NAME} ^www\.domain-online\.net$ [NC] RewriteRule ^ http://www.domain.com/ [L,R=301] RewriteCond %{SERVER_NAME} ^www\.domain\.eu$ [NC] RewriteRule ^ http://www.domain.com/ [L,R=301] RewriteCond %{SERVER_NAME} ^www\.domain\.dk$ [NC] RewriteRule ^ http://www.domain.com/ [L,R=301] RewriteCond %{SERVER_NAME} ^www\.domain\.ag$ [NC] RewriteRule ^ http://www.domain.com/ [L,R=301] RewriteCond %{SERVER_NAME} ^www\.domain\.se$ [NC] RewriteRule ^ http://www.domain.com/ [L,R=301] #------------------------------------------------------------------------Pages redirect START----------------------- #ENGLISH #FRANZÖSISCH #------------------------------------------------------------------------Pages redirect END----------------------- # 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] # END Adaptive-Images ------------------------------------------------------------------------------- # 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>
Genau. Und hier noch mit etwas besserer Formatierung: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 # Add language code ------------------------------------------------------------------------------- RewriteCond %{HTTP_HOST} intershop\.de$ [NC] RewriteRule ^(.*)$ http://dev.domain.com/de/$1 [R=301,L] RewriteCond %{HTTP_HOST} intershop\.nl$ [NC] RewriteRule ^(.*)$ http://dev.intershop.com/nl/$1 [R=301,L] RewriteCond %{HTTP_HOST} intershop\.fr$ [NC] RewriteRule ^(.*)$ http://dev.intershop.com/fr/$1 [R=301,L] # Adds www. to URLs without ---------------------------------------------------------------------- RewriteCond %{HTTP_HOST} ^domain\.de [NC] RewriteRule (.*) https://www.domain.de/$1 [R=301,L] RewriteCond %{HTTP_HOST} ^domain\.com [NC] RewriteRule (.*) https://www.domain.com/$1 [R=301,L] RewriteCond %{HTTP_HOST} ^domain\.fr [NC] RewriteRule (.*) https://www.domain.fr/$1 [R=301,L] RewriteCond %{HTTP_HOST} ^domain\.nl [NC] RewriteRule (.*) https://www.domain.nl/$1 [R=301,L] # Sitemaps ---------------------------------------------------------------------------------------- RewriteCond %{HTTP_HOST} ^(www.)?domain.com/de/$ RewriteRule sitemap.xml share/domainde.xml [L] RewriteCond %{HTTP_HOST} ^(www.)?domain.com/en/$ RewriteRule sitemap.xml share/domaincom.xml [L] RewriteCond %{HTTP_HOST} ^(www.)?domain.com/fr/$ RewriteRule sitemap.xml share/domainfr.xml [L] RewriteCond %{HTTP_HOST} ^(www.)?domain.com/nl/$ RewriteRule sitemap.xml share/domainnl.xml [L] # Domain redirects ------------------------------------------------------------------------------- RewriteCond %{SERVER_NAME} ^www\.domain-systems\.de$ [NC] RewriteRule ^ http://www.domain.de/ [L,R=301] RewriteCond %{SERVER_NAME} ^www\.domainsoftware\.de$ [NC] RewriteRule ^ http://www.domain.de/ [L,R=301] RewriteCond %{SERVER_NAME} ^www\.domain-online\.de$ [NC] RewriteRule ^ http://www.domain.de/ [L,R=301] RewriteCond %{SERVER_NAME} ^www\.domain.at RewriteRule ^ http://www.domain.de/ [L,R=301] RewriteCond %{SERVER_NAME} ^www\.domain24\.com$ [NC] RewriteRule ^ http://www.domain.com/ [L,R=301] RewriteCond %{SERVER_NAME} ^www\.domain24\.net RewriteRule ^ http://www.domain.com/ [L,R=301] RewriteCond %{SERVER_NAME} ^www\.domain\.info$ [NC] RewriteRule ^ http://www.domain.com/ [L,R=301] RewriteCond %{SERVER_NAME} ^www\.domain-online\.net$ [NC] RewriteRule ^ http://www.domain.com/ [L,R=301] RewriteCond %{SERVER_NAME} ^www\.domain\.eu$ [NC] RewriteRule ^ http://www.domain.com/ [L,R=301] RewriteCond %{SERVER_NAME} ^www\.domain\.dk$ [NC] RewriteRule ^ http://www.domain.com/ [L,R=301] RewriteCond %{SERVER_NAME} ^www\.domain\.ag$ [NC] RewriteRule ^ http://www.domain.com/ [L,R=301] RewriteCond %{SERVER_NAME} ^www\.domain\.se$ [NC] RewriteRule ^ http://www.domain.com/ [L,R=301] #------------------------------------------------------------------------Pages redirect START----------------------- #ENGLISH #FRANZÖSISCH #------------------------------------------------------------------------Pages redirect END----------------------- # 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] # END Adaptive-Images ------------------------------------------------------------------------------- # 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>
Funktioniert leider immer noch nicht.
Ich habe jetzt alle von mir eingefügten Redirects entfernt und nur Sprachcode Weiterleitungen drinnen gelassen:
wenn ich dev.domain.de aufrufe, werde ich auf : dev.domain.com/en/en/en/en/en/en/en/en/en/en/en/en/en/en/en/en/en/en/en/de/ weitergeleitet ist. Woher kommen denn die 19 mal "/en/"?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 RewriteCond %{HTTP_HOST} domain\.de$ [NC] RewriteRule ^(.*)$ http://dev.domain.com/de/$1 [R=301,L] RewriteCond %{HTTP_HOST} domain\.com$ [NC] RewriteRule ^(.*)$ http://dev.domain.com/en/$1 [R=301,L] RewriteCond %{HTTP_HOST} domain\.nl$ [NC] RewriteRule ^(.*)$ http://dev.domain.com/nl/$1 [R=301,L] RewriteCond %{HTTP_HOST} domain\.fr$ [NC] RewriteRule ^(.*)$ http://dev.domain.com/fr/$1 [R=301,L] # 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] #END Adaptive-Images ------------------------------------------------------------------------------- # 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>
Ja, weil du redirectest ja mit ^(.*)$ alles. Du darfst ja nur redirecten, wenn die die URL nicht schon bereits mit /de/ etc. beginnt. Siehe die Posts dazu vorher.
Er soll ja nur redirecten, wenn kein /de/, /en/, /nl/, /fr/ in der URL ist oder was ist das logischste?
Das haben wir ja wie gesagt hier schon besprochen.
Ich dachte, dass wäre das hier:
Code:RewriteCond %{HTTP_HOST} domain\.de$ [NC] RewriteRule ^(.*)$ http://dev.domain.com/de/$1 [R=301,L] RewriteCond %{HTTP_HOST} domain\.com$ [NC] RewriteRule ^(.*)$ http://dev.domain.com/en/$1 [R=301,L] RewriteCond %{HTTP_HOST} domain\.nl$ [NC] RewriteRule ^(.*)$ http://dev.domain.com/nl/$1 [R=301,L] RewriteCond %{HTTP_HOST} domain\.fr$ [NC] RewriteRule ^(.*)$ http://dev.domain.com/fr/$1 [R=301,L]
Nein, da steht jaDas heißt, du redirectest immer alles auf /en/. Das heißt https://example.com/foo wird auf https://example.com/en/foo weitergeleitet. Und https://example.com/en/foo wird auf https://example.com/en/en/foo weitergeleitet. Und https://example.com/en/en/foo wird auf https://example.com/en/en/en/foo weitergeleitet. Und https://example.com/en/en/en/foo wird auf https://example.com/en/en/en/en/foo weitergeleitet. etc.Code:RewriteRule ^(.*)$ http://dev.domain.com/en/$1
Puh ok, wie würdest du es denn machen, ist alles irgend wie neu für mich.
Eben genau so wie hier erwähnt.
Also wenn ich das so mache wie hier:
Dann werde ich immer weitergeleitet auf: dev.domain.com/en/app.phpCode:RewriteCond %{HTTP_HOST} domain\.de$ [NC] RewriteRule ^((?![a-z]{2}/).*)$ http://dev.domain.com/de/$1 [R=301,L] RewriteCond %{HTTP_HOST} domain\.com$ [NC] RewriteRule ^((?![a-z]{2}/).*)$ http://dev.domain.com/en/$1 [R=301,L] RewriteCond %{HTTP_HOST} domain\.nl$ [NC] RewriteRule ^((?![a-z]{2}/).*)$ http://dev.domain.com/nl/$1 [R=301,L] RewriteCond %{HTTP_HOST} domain\.fr$ [NC] RewriteRule ^((?![a-z]{2}/).*)$ http://dev.domain.com/fr/$1 [R=301,L]
Poste mal die komplette .htaccess inkl. dieser Änderung.
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 RewriteCond %{HTTP_HOST} domain\.de$ [NC] RewriteRule ^((?![a-z]{2}/).*)$ http://dev.domain.com/de/$1 [R=301,L] RewriteCond %{HTTP_HOST} domain\.com$ [NC] RewriteRule ^((?![a-z]{2}/).*)$ http://dev.domain.com/en/$1 [R=301,L] RewriteCond %{HTTP_HOST} domain\.nl$ [NC] RewriteRule ^((?![a-z]{2}/).*)$ http://dev.domain.com/nl/$1 [R=301,L] RewriteCond %{HTTP_HOST} domain\.fr$ [NC] RewriteRule ^((?![a-z]{2}/).*)$ http://dev.domain.com/fr/$1 [R=301,L] # 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] #END Adaptive-Images ------------------------------------------------------------------------------- # 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>
Sollte so stimmen.
Also du bekommst vom Server tatsächlich einen Response wo im Response Header Location: https://dev.intershop.com/en/app.php steht? Kann ich mir nicht erklären (und zumindest über einen .htaccess Tester nicht nachvollziehen).
Die Adresszeile wechselt von dev.domain.de auf: dev.domain.com/en/app.php.
Ärgert mich selber, dass ich mich damit Null auskenne.
Hatte hier auch mal einen Tester:
https://htaccess.madewithlove.be?sha...0-f2bf68cc7809
Könnte es sonst noch irgend wo Einstellungen zu Weiterleitungen geben? Server, Contao, Hoster?
Hi Spooky, gibt es denn eine Möglichkeit, die Automatische Weiterleitung anhand der Browsersprache aus zu schalten?
Grundsätzlich nicht. Aber warum möchtest du das abschalten?
Meine .de bzw com/de/ klappt, nur die .com/en nicht. http://dev.domain.com/solutions leitet immer auf http://dev.domain.com/de/solutions im Firefox (Browsersprache deutsch)
Weiter. In meinem Opera (Browsersprache englisch) leitet http://dev.domain.com/solutions immer auf http://dev.domain.com/en/solutions richtig weiter.
Ja, dafür brauchst du ja deine eigenen Redirect Regeln. Alle Anfragen, die auf dev.domain.com gehen, ohne Sprackürzel im Request Path, sollen auf /en/… weitergeleitet werden.
Genau und wenn ich das mache:
RewriteCond %{HTTP_HOST} domain\.com$ [NC]
RewriteRule ^((?![a-z]{2}/).*)$ http://dev.domain.com/en/$1 [R=301,L]
Wird immer weitergeleitet auf: http://dev.domain.com/en/app.php
Bildschirmfoto 2019-05-08 um 15.48.27.png
Ja, das hast du schon erwähnt. Ich kann aber momentan keinen Fehler feststellen und nicht nachvollziehen, wo das Problem liegt.
Dazu müsste ich mich näher mit dem Problem befassen. Wie du an der Länge des Threads sehen kannst, ist das alles keine ganz so triviale Sache. Daher wäre es vielleicht besser, wenn du dir bezahlte Unterstützung holst.
Aktive Benutzer in diesem Thema: 2 (Registrierte Benutzer: 0, Gäste: 2)