72 lines
		
	
	
		
			No EOL
		
	
	
		
			2 KiB
		
	
	
	
		
			ApacheConf
		
	
	
	
	
	
			
		
		
	
	
			72 lines
		
	
	
		
			No EOL
		
	
	
		
			2 KiB
		
	
	
	
		
			ApacheConf
		
	
	
	
	
	
# Enable URL rewriting
 | 
						|
RewriteEngine On
 | 
						|
 | 
						|
# Force HTTPS
 | 
						|
RewriteCond %{HTTPS} off
 | 
						|
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
 | 
						|
 | 
						|
# Remove trailing slashes
 | 
						|
RewriteCond %{REQUEST_FILENAME} !-d
 | 
						|
RewriteRule ^(.*)/$ /$1 [L,R=301]
 | 
						|
 | 
						|
# Remove .php extension
 | 
						|
RewriteCond %{REQUEST_FILENAME} !-d
 | 
						|
RewriteCond %{REQUEST_FILENAME}.php -f
 | 
						|
RewriteRule ^(.*)$ $1.php [L]
 | 
						|
 | 
						|
# Browser caching for static resources
 | 
						|
<IfModule mod_expires.c>
 | 
						|
    ExpiresActive On
 | 
						|
    ExpiresByType image/jpg "access plus 1 year"
 | 
						|
    ExpiresByType image/jpeg "access plus 1 year"
 | 
						|
    ExpiresByType image/png "access plus 1 year"
 | 
						|
    ExpiresByType image/gif "access plus 1 year"
 | 
						|
    ExpiresByType text/css "access plus 1 month"
 | 
						|
    ExpiresByType application/javascript "access plus 1 month"
 | 
						|
</IfModule>
 | 
						|
 | 
						|
# Enable compression
 | 
						|
<IfModule mod_deflate.c>
 | 
						|
    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
 | 
						|
</IfModule>
 | 
						|
 | 
						|
# Security headers
 | 
						|
<IfModule mod_headers.c>
 | 
						|
    Header set X-Content-Type-Options "nosniff"
 | 
						|
    Header set X-XSS-Protection "1; mode=block"
 | 
						|
    Header set X-Frame-Options "SAMEORIGIN"
 | 
						|
    Header set Referrer-Policy "strict-origin-when-cross-origin"
 | 
						|
</IfModule>
 | 
						|
 | 
						|
# Prevent directory listing
 | 
						|
Options -Indexes
 | 
						|
 | 
						|
# Protect sensitive files
 | 
						|
<FilesMatch "^\.">
 | 
						|
    Order allow,deny
 | 
						|
    Deny from all
 | 
						|
</FilesMatch>
 | 
						|
 | 
						|
<FilesMatch "\.(json|txt|log|cache)$">
 | 
						|
    Order allow,deny
 | 
						|
    Deny from all
 | 
						|
</FilesMatch>
 | 
						|
 | 
						|
# Allow access to visits.json specifically
 | 
						|
<Files "visits.json">
 | 
						|
    Order allow,deny
 | 
						|
    Allow from all
 | 
						|
</Files>
 | 
						|
 | 
						|
# Custom error pages
 | 
						|
ErrorDocument 404 /404.php
 | 
						|
ErrorDocument 403 /403.php
 | 
						|
ErrorDocument 500 /500.php |