.htaccess

From Jens\\\\\\\' Wiki
Revision as of 22:57, 16 January 2021 by Jens (talk | contribs) (Created page with "Tvinger browseren til at benytte https versionen <code apache>RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://domain.tld/$1 [R,L]</code> Sender al...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Tvinger browseren til at benytte https versionen RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://domain.tld/$1 [R,L]

Sender alt trafik fra www.domain.tld over til domain.tld RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

Gør det muligt at linke til en side, uden at de skal slutte på .php eller .html RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.php [NC,L]

Komprimere filer

  1. compress text, html, javascript, css, xml:

AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE text/xml AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE application/xml AddOutputFilterByType DEFLATE application/xhtml+xml AddOutputFilterByType DEFLATE application/rss+xml AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE application/x-javascript

Sætter expiry længde <ifModule mod_expires.c>

 ExpiresActive On
 ExpiresByType image/gif "access plus 2592000 seconds"
 ExpiresByType image/jpeg "access plus 2592000 seconds"
 ExpiresByType image/png "access plus 2592000 seconds"
 ExpiresByType text/css "access plus 2592000 seconds"
 ExpiresByType application/javascript "access plus 2592000 seconds"
</ifModule>

Sætter 403 på en fil <files FILE.TYPE>

  order allow,deny 
  deny from all 

</files>

Definere error dokumenter ErrorDocument 404 /404.php