Skip to content

Instantly share code, notes, and snippets.

@ADoebeling ADoebeling/.htaccess

Last active Aug 8, 2017
Embed
What would you like to do?
.htaccess-defaults
# .htaccess-defaults
# Some often used .htaccess-parameters
#
# @Author: Andreas Doebeling <ad@1601.com>
# @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 admin@1601.com"
#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

This comment has been minimized.

Copy link

Xendiadyon commented Oct 5, 2016

In Z.24 sollte der Punkt auch escaped sein:
!^DOMAIN\.TLD$

@ADoebeling

This comment has been minimized.

Copy link
Owner Author

ADoebeling commented Dec 10, 2016

@Xendiadyon Schönheitsfehler ;-) fixed.

@LBeckX

This comment has been minimized.

Copy link

LBeckX commented Jan 27, 2017

# 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

@ADoebeling

This comment has been minimized.

Copy link
Owner Author

ADoebeling commented Jan 27, 2017

@LBeckX Danke, done!

@Xendiadyon

This comment has been minimized.

Copy link

Xendiadyon commented Jan 31, 2017

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]
@LBeckX

This comment has been minimized.

Copy link

LBeckX commented Feb 24, 2017

.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]
@LBeckX

This comment has been minimized.

Copy link

LBeckX commented Mar 20, 2017

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 admin@1601.com"
AuthUserFile /kunden/226796_91058/kunden/lbv.de/www/.htpasswd
AuthMerging And
Require valid-user
</If>

Quelle: 1601com/Meetings#5

@Xendiadyon

This comment has been minimized.

Copy link

Xendiadyon commented May 4, 2017

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]
@ao1601com

This comment has been minimized.

Copy link

ao1601com commented Aug 8, 2017

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]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.