.htaccess file use code example

Example 1: .htaccess

##Add a Trailing slash
# FROM:  http://was-mit-internet.de/unterseite/filename.html
# TO: http://was-mit-internet.de/unterseite
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ https://www.domainname.tld/$1/ [L,R=301]

Example 2: .htaccess

# Browser Caching
ExpiresActive On
ExpiresByType image/jpg "access 1 month"
ExpiresByType image/jpeg "access 1 month"
ExpiresByType image/gif "access 1 month"
ExpiresByType image/png "access 1 month"
ExpiresByType image/x-icon "access 1 month"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresDefault "access 3 days"

Tags:

Php Example