/ .htaccess
.htaccess
 1  # Enable URL rewriting
 2  RewriteEngine On
 3  
 4  # Handle blog directory as index
 5  DirectoryIndex index.html
 6  
 7  # Ensure homepage works without trailing slash
 8  RewriteRule ^$ /index.html [L]
 9  
10  # Redirect trailing slashes to clean URLs (except for directories)
11  RewriteCond %{REQUEST_FILENAME} !-d
12  RewriteCond %{THE_REQUEST} /([^?\s]*)/+[?\s]
13  RewriteRule ^(.+)/$ /$1 [R=301,L]
14  
15  # Redirect old admin URLs to new pages structure
16  RewriteRule ^admin/(.*)$ /pages/$1 [R=301,L]
17  
18  # Redirect old blog.html to blog/
19  RewriteRule ^blog/blog\.html$ /blog/ [R=301,L]
20  
21  # Remove .html extension from URLs
22  RewriteCond %{REQUEST_FILENAME} !-d
23  RewriteCond %{REQUEST_FILENAME} !-f
24  RewriteRule ^([^\.]+)$ $1.html [NC,L]
25  
26  # Redirect .html URLs to clean URLs
27  RewriteCond %{THE_REQUEST} /([^.]+)\.html [NC]
28  RewriteRule ^ /%1 [NC,L,R=301]
29  
30  # Handle specific routes for films
31  RewriteRule ^films/community/?$ films/community.html [NC,L]
32  RewriteRule ^films/love1/?$ films/love1.html [NC,L]
33  RewriteRule ^films/lovers/?$ films/lovers.html [NC,L]
34  RewriteRule ^films/horror/?$ films/horror.html [NC,L]
35  
36  # Handle blog routes
37  RewriteRule ^blog/?$ blog/index.html [NC,L]
38  RewriteRule ^blog/articles/([^/]+)/?$ blog/articles/$1.html [NC,L]
39  
40  # Handle pages routes
41  RewriteRule ^pages/([^/]+)/?$ pages/$1.html [NC,L]
42  
43  # Ensure proper MIME types
44  AddType text/html .html
45  AddType text/css .css
46  AddType application/javascript .js
47  AddType image/svg+xml .svg
48  
49  # Security headers
50  Header always set X-Content-Type-Options nosniff
51  Header always set X-Frame-Options DENY
52  Header always set X-XSS-Protection "1; mode=block"
53  
54  # Cache control for static assets
55  <FilesMatch "\.(css|js|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|otf)$">
56      ExpiresActive On
57      ExpiresDefault "access plus 1 year"
58      Header set Cache-Control "public, immutable"
59  </FilesMatch>
60  
61  # Cache control for HTML files
62  <FilesMatch "\.html$">
63      ExpiresActive On
64      ExpiresDefault "access plus 1 hour"
65      Header set Cache-Control "public, must-revalidate"
66  </FilesMatch>