-
-
Save ADoebeling/2a327f9ba27863ec7eed to your computer and use it in GitHub Desktop.
# .htaccess-defaults | |
# Some often used .htaccess-parameters | |
# | |
# @Author: Andreas Doebeling <[email protected]> | |
# @Copyright: 1601.communication gmbh | |
# @Link: http://www.1601.com | |
# @Link: http://xing.doebeling.de | |
# Always required at 1601-Hosting | |
RewriteEngine on | |
RewriteBase / | |
# HTTP-Auth | |
#AuthType Basic | |
#AuthName "Freigabeserver - contact [email protected]" | |
#AuthUserFile /path/to/.htpasswd | |
#Require valid-user | |
# Block all requests | |
#ErrorDocument 403 http://www.domain.tkd | |
#Deny from all | |
# Redirect all mapped domains to primary domain | |
#RewriteCond %{HTTP_HOST} !^DOMAIN\.TLD$ [nc] | |
#RewriteRule (.*) http://DOMAIN.TLD/$1 [R=permanent,nc,L] | |
# Redirect single domains | |
#RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC] | |
#RewriteRule (.*) http://example.com/$1 [R=301,L] | |
# Require https | |
#RewriteCond %{SERVER_PORT} !^443$ [nc] | |
#RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=permanent,nc,L] | |
# Rewrite favicon.ico on multisite-installations | |
#RewriteCond %{HTTP_HOST} ^(www\.)?domain1\.de$ [NC] | |
#RewriteRule ^favicon.ico$ /files/domain1/layout/favicon.ico [L] | |
#RewriteCond %{HTTP_HOST} ^(www\.)?domain2\.de$ [NC] | |
#RewriteRule ^favicon.ico$ /files/domain2/layout/favicon.ico [L] | |
# Redirect / to subdir | |
#RewriteRule ^$ /contenido/ [R=301,L] | |
# SEO-Redirects (with path) | |
#RedirectPermanent /oldUrl /newUrl | |
# SEO-Redirects (without path, case-insensitive) | |
#RedirectMatch Permanent (?i)/oldUrl /newUrl | |
# Shortlink w/ monitoring | |
#RewriteCond %{HTTP_HOST} ^(www\.)?jobs.xxx\.de$ [NC] | |
#RewriteRule (.*) https://www.xxx.de/jobs [R=301,L] | |
#RedirectMatch Permanent ^(?i)/jobs /de/unternehmen/jobs.html | |
# SEO/Performance | |
#Header set Connection keep-alive | |
# Support httpAuth at fast-cgi | |
#RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L] | |
# Proxy-Rewriting | |
#RewriteCond %{REQUEST_FILENAME} !-d | |
#RewriteCond %{REQUEST_FILENAME} !-f | |
#RewriteRule ^(.*)$ https://xxx.tld/$1 [L,P] | |
# Error Document | |
#ErrorDocument 404 /error-404.html | |
#ErrorDocument 403 /error-403.html | |
# Fixing old allow/deny from all in subfolders (of contao) | |
# == OLD == | |
# order deny,allow | |
# #allow from all | |
# == NEW == | |
# <IfModule !mod_authz_core.c> | |
# Order deny,allow | |
# Allow from all | |
# </IfModule> | |
# <IfModule mod_authz_core.c> | |
# Require all granted | |
# </IfModule> |
@Xendiadyon Schönheitsfehler ;-) fixed.
# Redirect single domains
#RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
#RewriteRule (.*) http://example.com/$1 [R=301,L]
hier sollte m. E. ^www\.example\.com$
zu ^(www\.)?example\.com$
geändert werden
@LBeckX Danke, done!
hier fehlt noch das Hinzufügen von Slashes falls sie weggelassen sind und man URLs ohne .html und stattdessen mit / generieren lässt.
# add trailing slashes if not set (only with / as url suffix)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)([^/])$ /$1$2/ [L,R=301]
.html auf /
RewriteRule ^(.*)\.html$ $1/ [R=301,L]
- Contao.htaccess URL-Suffix = /
RewriteCond %{REQUEST_FILENAME} !\.(htm|php|js|css|map|htc|png|gif|jpe?g|ico|xml|csv|txt|swf|flv|mp4|webm|ogv|mp3|ogg|oga|eot|otf|tt[cf]|woff2?|svgz?|pdf|zip|gz)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]
Wir haben die Möglichkeit, HTTP-Requests von der Passwortabfrage auszunehmen.
Somit wird ZUERST eine Weiterleitung auf https erzwungen, UND DANN ERST findet eine Passwortabfrage statt (bei der das Passwort dann praktischerweise auch direkt verschlüsselt übertragen wird).
In meinen Augen deutlich sinnvoller und angenehmer: Nur eine Passwortabfrage und nicht 2-5 ;)Einen Nachteil hat es aber:
Wenn der HTTPS-Zwang nicht funktioniert oder nicht eingeschaltet ist, ist die Seite logischerweise uneingeschränkt per HTTP erreichbar.
Man muss also sein Hirn einschalten und den (sowieso obligatorischen) HTTPS-Zwang auf jeden Fall mit einbinden.
<If "%{HTTPS} == 'on'">
AuthType Basic
AuthName "Freigabeserver - contact [email protected]"
AuthUserFile /kunden/226796_91058/kunden/lbv.de/www/.htpasswd
AuthMerging And
Require valid-user
</If>
Quelle: https://github.com/ADoebeling/Digital-Meeting/issues/5
außerdem fehlt noch die bessere Möglichkeit, um SSL zu aktivieren:
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,QSA,L]
Weiterleitung domainspezifischer Sitemap
RewriteCond %{HTTP_HOST} ^(www\.)?domain1\.de$ [NC]
RewriteRule ^sitemap.xml$ share/sitemap1.xml [R=301,L]
RewriteCond %{HTTP_HOST} ^(www\.)?domain2\.de$ [NC]
RewriteRule ^sitemap.xml$ share/sitemap2.xml [R=301,L]
In Z.24 sollte der Punkt auch escaped sein:
!^DOMAIN\.TLD$