zurück zur Startseite
  


Zurück XHTMLforum > Webentwicklung (außer XHTML und CSS) > Serveradministration und serverseitige Scripte
Seite neu laden htaccess

Antwort
 
LinkBack Themen-Optionen Ansicht
  #1 (permalink)  
Alt 07.02.2022, 19:18
Neuer Benutzer
neuer user
Thread-Ersteller
 
Registriert seit: 23.10.2021
Beiträge: 24
Dachlatte befindet sich auf einem aufstrebenden Ast
Standard htaccess

Guten Abend,
ich habe unsere Seite neu gemacht und bin jetzt noch dabei die Dinge im Hintergrund besser und vielleicht auch schneller zu machen. Die Zeilen in der htaccess habe ich mir aber schon immer zusammenkopieren müssen.. ich steige da einfach nicht durch

Code:
<ifmodule mod_headers.c>
  DefaultLanguage de
  
  # Header set X-XSS-Protection "1; mode=block"
  # X-XSS-Protection: 1; mode=block  / 13012021
  
  # Header set X-Frame-Options "sameorigin"
  # X-Frame-Options: SAMEORIGIN  / 13012021
  
  # Header set X-Content-Type-Options "nosniff"
  # X-Content-Type-Options: nosniff  / 13012021
  
  # Header set X-Permitted-Cross-Domain-Policies "none"  / 13012021
  
  # Use HTTP Strict Transport Security to force client to use secure connections only 
  # Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" env=HTTPS
  # Header set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
  # Header always set Strict-Transport-Security: "max-age=31536000; includeSubDomains" env=HTTPS
  # Strict-Transport-Security: "max-age=31536000; includeSubDomains" env=HTTPS  / 13012021
  
  # Header set Content-Security-Policy "default-src * data:; script-src https: 'unsafe-inline' 'unsafe-eval'; style-src https: 'unsafe-inline'"
  ### Header set Content-Security-Policy: default-src 'self'
  # Header set Content-Security-Policy-Report-Only: policy 
  
  # Header set Referrer-Policy "no-referrer-when-downgrade"
  # Referrer-Policy: no-referrer
  # <meta name="referrer" content="no-referrer, same-origin">
  # Header set Referrer-Policy: no-referrer  / 13012021
  
  
  # Header set Expect-CT: enforce, max-age=31536000, report-uri="https://your.report-uri.com/r/d/ct/enforce"
  
  <FilesMatch "\.(js|css|xml|gz)$"> 
    Header append Vary Accept-Encoding 
  </FilesMatch> 
  
  <FilesMatch "\.(gif|ico|jpeg|jpg|png|css|js|webp|mp4)$">
    Header set Cache-Control "max-age=604800, public"
  </FilesMatch>

</IfModule>


<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]
 
RewriteCond %{HTTP_HOST} ^wipfelglueck\.de$
RewriteRule ^(.*)$ https://www.wipfelglueck.de/$1 [R=301,L]
 
 
 # RewriteRule index.html$ /index.php    
 # RewriteCond %{REQUEST_URI} ^(.*)\.php$
 # RewriteRule ^(.*)\.html$ $1.php [nc,L]

</IfModule>

 <IfModule mod_deflate.c> 
 # Insert filters / compress text, html, javascript, css, xml: 
 AddOutputFilterByType DEFLATE text/plain 
 AddOutputFilterByType DEFLATE text/javascript 
 AddOutputFilterByType DEFLATE text/html 
 AddOutputFilterByType DEFLATE text/xml 
 AddOutputFilterByType DEFLATE text/css 
 AddOutputFilterByType DEFLATE text/vtt  
 AddOutputFilterByType DEFLATE text/x-component 
 AddOutputFilterByType DEFLATE application/xml 
 AddOutputFilterByType DEFLATE application/xhtml+xml 
 AddOutputFilterByType DEFLATE application/rss+xml 
 AddOutputFilterByType DEFLATE application/js 
 AddOutputFilterByType DEFLATE application/javascript 
 AddOutputFilterByType DEFLATE application/x-javascript 
 AddOutputFilterByType DEFLATE application/x-httpd-php 
 AddOutputFilterByType DEFLATE application/x-httpd-fastphp 
 AddOutputFilterByType DEFLATE application/atom+xml  
 AddOutputFilterByType DEFLATE application/json 
 AddOutputFilterByType DEFLATE application/ld+json  
 AddOutputFilterByType DEFLATE application/vnd.ms-fontobject  
 AddOutputFilterByType DEFLATE application/x-font-ttf  
 AddOutputFilterByType DEFLATE application/x-web-app-manifest+json  
 AddOutputFilterByType DEFLATE font/opentype  
 AddOutputFilterByType DEFLATE image/svg+xml 
 AddOutputFilterByType DEFLATE image/x-icon  

 
# Exception: Images 
SetEnvIfNoCase REQUEST_URI \.(?:gif|jpg|jpeg|png)$ no-gzip dont-vary 

 
# Drop problematic browsers 
BrowserMatch ^Mozilla/4 gzip-only-text/html 
BrowserMatch ^Mozilla/4\.0[678] no-gzip 
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html 
 
</IfModule> 

<IfModule mod_gzip.c> 
   mod_gzip_on Yes 
   mod_gzip_dechunk Yes 
   mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$ 
   mod_gzip_item_include handler ^cgi-script$ 
   mod_gzip_item_include mime ^text/.* 
   mod_gzip_item_include mime ^application/x-javascript.* 
   mod_gzip_item_exclude mime ^image/.* 
   mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.* 
</IfModule> 


# turns cache on
# <IfModule mod_expires.c>
#  ExpiresActive On      
#  FileETag MTime Size
#  ExpiresByType text/html "access plus 500 seconds"
#  ExpiresByType image/gif "access plus 14 days"
#  ExpiresByType image/ico "access plus 14 days"
#  ExpiresByType image/jpeg "access plus 14 days"
#  ExpiresByType image/jpg "access plus 14 days"
#  ExpiresByType image/png "access plus 14 days"
#  ExpiresByType image/webp "access plus 14 days"
#  ExpiresByType text/css "access plus 500 seconds"
#  ExpiresByType text/javascript "access plus 500 seconds"
#  ExpiresByType application/x-javascript "access plus 500 seconds"
#  ExpiresByType application/javascript "access plus 500 seconds"
# </IfModule>
 
 


## Cache Expiration ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/html "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 1 month"
</IfModule>
## Cache Expiration
Kann mir bitte jemand sagen wie ich hier den Cache ordentlich aktiviere? Mit Google PageSpeed Insights wird mir die ganze Zeit angezeigt dass ich doch bitte die Files cachen soll. Was mache ich denn bitte falsch?
Wenn noch jemand etwas sagen könnte zu den Security-Headern wäre das auch total toll. Da komme ich mit den Hilfen im Web auch nicht weiter. Das mit dem CDN hatte ich mal hinbekommen, aber das war es meine ich dann auch..
Aber vor allem geht es mir im Moment um den Cache!
Besten Dank für Eure Unterstützung!
Gruß
Stefan
Mit Zitat antworten
Sponsored Links
  #2 (permalink)  
Alt 08.02.2022, 12:03
top top ist offline
Benutzer
neuer user
 
Registriert seit: 06.01.2021
Beiträge: 60
top wird schon bald berühmt werden
Standard

Hi,
meine (zusammenkopierte) .htaccass sieht aktuell folgendermaßen aus:

Code:
# HTTPS erzwingen und www. ergaenzen/entfernen
RewriteEngine On

# Umleitung auf www. und HTTPS erzwingen
# RewriteCond %{HTTP_HOST} !^www\.
# RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
# RewriteCond %{HTTPS} off
# RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]

# Entferne www. und erzwinge HTTPS 
# RewriteCond %{HTTPS} off [OR]
# RewriteCond %{HTTP_HOST} ^www\. [NC]
# RewriteRule ^(.*)$ https://example.com%{REQUEST_URI} [R=301,L]

# Gzip
<IfModule mod_mime.c>
	AddType text/javascript                js
	AddType application/vnd.ms-fontobject  eot
	AddType font/ttf                       ttf
	AddType font/otf                       otf
	AddType font/woff                      woff
	AddType font/woff2                     woff2
	AddType image/webp                     webp
	AddType image/svg+xml                  svg 
	AddType image/svg+xml                  svgz
	AddEncoding gzip                       svgz
</Ifmodule>

# Ablaufzeiten festlegen
<IfModule mod_expires.c>
	ExpiresActive on
	ExpiresDefault "access plus 5 minutes"
	ExpiresByType image/ico "access plus 1 year"
	ExpiresByType image/jpg "access plus 4 month"
	ExpiresByType image/jpeg "access plus 4 month"
	ExpiresByType image/gif "access plus 4 month"
	ExpiresByType image/png "access plus 4 month"
	ExpiresByType image/webp "access plus 4 month"
	ExpiresByType application/vnd.ms-fontobject "access plus 4 month"
	ExpiresByType font/ttf "access plus 4 month"
	ExpiresByType font/otf "access plus 4 month"
	ExpiresByType font/woff "access plus 4 month"
	ExpiresByType font/woff2 "access plus 4 month"
	ExpiresByType image/svg+xml "access plus 4 month"
	ExpiresByType application/x-shockwave-flash "access plus 4 month"
	ExpiresByType text/html "access plus 4 hours"
	ExpiresByType text/htm "access plus 4 hours"
	ExpiresByType text/javascript "access plus 32 days"
	ExpiresByType text/css "access plus 32 days"
	ExpiresByType text/xml "access plus 7 days"
	ExpiresByType application/xml "access plus 0 seconds"
	ExpiresByType application/json "access plus 0 seconds"
	ExpiresByType text/cache-manifest "access plus 0 seconds"
	ExpiresByType video/ogg "access plus 4 month"
	ExpiresByType audio/ogg "access plus 4 month"
	ExpiresByType video/mp4 "access plus 4 month"
	ExpiresByType video/webm "access plus 4 month"
	ExpiresByType video/m4v "access plus 4 month"
	ExpiresByType video/ogv "access plus 4 month"
</IfModule>


# Komprimierung aktivieren
<IfModule mod_headers.c>
	AddOutputFilterByType DEFLATE text/plain text/html text/xml text/css text/javascript
	AddOutputFilterByType DEFLATE application/xml
	AddOutputFilterByType DEFLATE application/rss+xml
	AddOutputFilterByType DEFLATE application/javascript application/x-javascript
	AddOutputFilterByType DEFLATE image/svg+xml

  # Ausnahmen
	BrowserMatch ^Mozilla/4\.0[678] no-gzip
	BrowserMatch \bMSIE\s7 !no-gzip !gzip-only-text/html
</IfModule>
Im Laufe der Jahre kamen da immer mal wieder Dinge dazu oder wurden angepasst. (Z.B. reichten Pagespeed früher kürzere Ablaufzeiten.) Eigentlich müsste ich da mal ausmisten. Ich denke z. B. "Shockwafe Flash" werde ich nicht mehr brauchen.
Mit Zitat antworten
Sponsored Links
  #3 (permalink)  
Alt 09.02.2022, 14:31
top top ist offline
Benutzer
neuer user
 
Registriert seit: 06.01.2021
Beiträge: 60
top wird schon bald berühmt werden
Standard

Ach ja, fast vergessen - bei Kunden-Seiten die ihren Webspace bei 1und1/IONOS haben, packe ich das hier noch dazu:

Code:
# alternative 404-Seite statt sch*** Sedo-Werbung von 1und1/IONOS anzeigen
ErrorDocument 404 /404.html
Mit Zitat antworten
Antwort

Stichwörter
htaccess cache

Themen-Optionen
Ansicht

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus


Ähnliche Themen
Thema Autor Forum Antworten Letzter Beitrag
301 umleitung in der htaccess - bester code irmen Serveradministration und serverseitige Scripte 4 11.04.2017 13:48
htaccess Weiterleitung einer Seite in einer Subdomain celine@23 Serveradministration und serverseitige Scripte 2 09.07.2013 11:54
Eine Frage zur htaccess Praktiker Serveradministration und serverseitige Scripte 2 16.05.2013 15:20
Problem mit htaccess till.kaufmann Serveradministration und serverseitige Scripte 1 23.02.2011 12:46
htaccess redirect/rewrite Chrunchy Serveradministration und serverseitige Scripte 11 03.02.2011 17:43


Alle Zeitangaben in WEZ +2. Es ist jetzt 16:12 Uhr.