|
1 | | -# ============================================================ |
2 | | -# School of Freelancing — .htaccess (cPanel / Apache) |
3 | | -# ============================================================ |
| 1 | +############################################ |
| 2 | +# School Of Freelancing |
| 3 | +############################################ |
| 4 | +Options -Indexes |
| 5 | +DirectoryIndex index.html |
| 6 | +RewriteEngine On |
4 | 7 |
|
5 | | -# ---- PHP Error Handling ---- |
6 | | -php_flag display_errors Off |
7 | | -php_value error_reporting 0 |
| 8 | +################################################## |
| 9 | +# Localhost only (no HTTPS/WWW force) |
| 10 | +################################################## |
| 11 | +RewriteCond %{HTTP_HOST} ^(localhost|127\.0\.0\.1)$ [NC] |
| 12 | +RewriteRule ^ - [L] |
8 | 13 |
|
9 | | -# ---- Enable Compression ---- |
10 | | -<IfModule mod_deflate.c> |
11 | | - AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css |
12 | | - AddOutputFilterByType DEFLATE application/javascript application/json |
13 | | - AddOutputFilterByType DEFLATE application/xml application/xhtml+xml |
14 | | -</IfModule> |
| 14 | +################################################## |
| 15 | +# Redirect /index.html to / |
| 16 | +################################################## |
| 17 | +RewriteRule ^index\.html$ / [R=301,L] |
15 | 18 |
|
16 | | -# ---- Browser Caching ---- |
17 | | -<IfModule mod_expires.c> |
18 | | - ExpiresActive On |
19 | | - ExpiresByType text/html "access plus 1 hour" |
20 | | - ExpiresByType text/css "access plus 1 month" |
21 | | - ExpiresByType application/javascript "access plus 1 month" |
22 | | - ExpiresByType image/jpeg "access plus 6 months" |
23 | | - ExpiresByType image/png "access plus 6 months" |
24 | | - ExpiresByType image/gif "access plus 6 months" |
25 | | - ExpiresByType image/svg+xml "access plus 6 months" |
26 | | - ExpiresByType image/webp "access plus 6 months" |
27 | | - ExpiresByType font/woff2 "access plus 1 year" |
28 | | -</IfModule> |
| 19 | +################################################## |
| 20 | +# Redirect directory index.html to / |
| 21 | +################################################## |
| 22 | +RewriteRule ^(.+)/index\.html$ /$1/ [R=301,L] |
29 | 23 |
|
30 | | -# ---- Security Headers ---- |
31 | | -<IfModule mod_headers.c> |
32 | | - Header always set X-Frame-Options "SAMEORIGIN" |
33 | | - Header always set X-Content-Type-Options "nosniff" |
34 | | - Header always set X-XSS-Protection "1; mode=block" |
35 | | - Header always set Referrer-Policy "strict-origin-when-cross-origin" |
36 | | - Header always set Permissions-Policy "geolocation=(), microphone=(), camera=()" |
37 | | -</IfModule> |
| 24 | +################################################## |
| 25 | +# Redirect old flat HTML pages to clean folders |
| 26 | +################################################## |
| 27 | +RewriteRule ^training\.html$ /training/ [R=301,L] |
| 28 | +RewriteRule ^enrollment\.html$ /training/enroll/ [R=301,L] |
| 29 | +RewriteRule ^tech-support\.html$ /tech-support/ [R=301,L] |
| 30 | +RewriteRule ^support\.html$ /tech-support/ [R=301,L] |
| 31 | +RewriteRule ^get-support\.html$ /tech-support/get-support/ [R=301,L] |
| 32 | +RewriteRule ^get_support\.html$ /tech-support/get-support/ [R=301,L] |
| 33 | +RewriteRule ^testimonials\.html$ /testimonials/ [R=301,L] |
| 34 | +RewriteRule ^about\.html$ /about/ [R=301,L] |
| 35 | +RewriteRule ^faq\.html$ /faq/ [R=301,L] |
| 36 | +RewriteRule ^privacy-policy\.html$ /privacy-policy/ [R=301,L] |
| 37 | +RewriteRule ^terms\.html$ /terms/ [R=301,L] |
| 38 | +RewriteRule ^contact\.html$ /contact/ [R=301,L] |
38 | 39 |
|
39 | | -# ---- Force HTTPS ---- |
40 | | -<IfModule mod_rewrite.c> |
41 | | - RewriteEngine On |
42 | | - RewriteCond %{HTTPS} off |
43 | | - RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] |
44 | | -</IfModule> |
| 40 | +################################################## |
| 41 | +# Internally load index.html for clean folder URLs |
| 42 | +################################################## |
| 43 | +RewriteCond %{REQUEST_FILENAME} !-f |
| 44 | +RewriteCond %{REQUEST_FILENAME} !-d |
| 45 | +RewriteCond %{DOCUMENT_ROOT}/$1/index.html -f |
| 46 | +RewriteRule ^(.+?)/?$ $1/index.html [L] |
45 | 47 |
|
46 | | -# ---- Remove www (optional — comment out to keep www) ---- |
47 | | -# <IfModule mod_rewrite.c> |
48 | | -# RewriteEngine On |
49 | | -# RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] |
50 | | -# RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L] |
51 | | -# </IfModule> |
52 | | - |
53 | | -# ---- Custom Error Pages ---- |
54 | | -ErrorDocument 404 /404.html |
55 | | -ErrorDocument 500 /500.html |
| 48 | +################################################## |
| 49 | +# Browser Cache |
| 50 | +################################################## |
| 51 | +<IfModule mod_expires.c> |
| 52 | + ExpiresActive On |
| 53 | + ExpiresByType text/html "access plus 0 seconds" |
| 54 | + ExpiresByType text/css "access plus 30 days" |
| 55 | + ExpiresByType application/javascript "access plus 30 days" |
| 56 | + ExpiresByType image/jpeg "access plus 1 year" |
| 57 | + ExpiresByType image/png "access plus 1 year" |
| 58 | + ExpiresByType image/gif "access plus 1 year" |
| 59 | + ExpiresByType image/webp "access plus 1 year" |
| 60 | + ExpiresByType image/svg+xml "access plus 1 year" |
| 61 | + ExpiresByType image/x-icon "access plus 1 year" |
| 62 | + ExpiresByType font/woff "access plus 1 year" |
| 63 | + ExpiresByType font/woff2 "access plus 1 year" |
| 64 | + ExpiresByType application/font-woff2 "access plus 1 year" |
| 65 | +</IfModule> |
56 | 66 |
|
57 | | -# ---- Protect sensitive files ---- |
58 | | -<FilesMatch "(\.htaccess|\.htpasswd|\.env|composer\.json|package\.json)$"> |
59 | | - Order Allow,Deny |
60 | | - Deny from all |
61 | | -</FilesMatch> |
| 67 | +################################################## |
| 68 | +# GZIP Compression |
| 69 | +################################################## |
| 70 | +<IfModule mod_deflate.c> |
| 71 | + AddOutputFilterByType DEFLATE text/plain |
| 72 | + AddOutputFilterByType DEFLATE text/html |
| 73 | + AddOutputFilterByType DEFLATE text/xml |
| 74 | + AddOutputFilterByType DEFLATE text/css |
| 75 | + AddOutputFilterByType DEFLATE application/javascript |
| 76 | + AddOutputFilterByType DEFLATE application/json |
| 77 | + AddOutputFilterByType DEFLATE application/xml |
| 78 | + AddOutputFilterByType DEFLATE image/svg+xml |
| 79 | +</IfModule> |
62 | 80 |
|
63 | | -# ---- MIME Types ---- |
64 | | -<IfModule mod_mime.c> |
65 | | - AddType application/javascript .js |
66 | | - AddType text/css .css |
67 | | - AddType image/svg+xml .svg |
68 | | - AddType font/woff2 .woff2 |
| 81 | +################################################## |
| 82 | +# Security Headers |
| 83 | +################################################## |
| 84 | +<IfModule mod_headers.c> |
| 85 | + Header always set X-Frame-Options SAMEORIGIN |
| 86 | + Header always set X-Content-Type-Options nosniff |
| 87 | + Header always set Referrer-Policy strict-origin-when-cross-origin |
| 88 | + Header always set Permissions-Policy "camera=(), microphone=(), geolocation=()" |
69 | 89 | </IfModule> |
0 commit comments