-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.htaccess
More file actions
122 lines (99 loc) · 3.37 KB
/
.htaccess
File metadata and controls
122 lines (99 loc) · 3.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# Project Structure Viewer - Apache Configuration
# This file optimizes the web server configuration for better performance and security
# Enable URL rewriting
RewriteEngine On
# Set default index file
DirectoryIndex index.php
# Pretty URLs - redirect everything to index.php (optional)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]
# Security Headers
<IfModule mod_headers.c>
# Prevent MIME type sniffing
Header always set X-Content-Type-Options nosniff
# Prevent clickjacking
Header always set X-Frame-Options DENY
# Enable XSS protection
Header always set X-XSS-Protection "1; mode=block"
# Referrer policy
Header always set Referrer-Policy "strict-origin-when-cross-origin"
# Content Security Policy (basic)
Header always set Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data:;"
</IfModule>
# Disable directory browsing
Options -Indexes
# Protect sensitive files
<Files "composer.json">
Order allow,deny
Deny from all
</Files>
<Files "composer.lock">
Order allow,deny
Deny from all
</Files>
<Files "*.md">
Order allow,deny
Deny from all
</Files>
<Files ".gitignore">
Order allow,deny
Deny from all
</Files>
<Files "*.log">
Order allow,deny
Deny from all
</Files>
# Protect vendor directory if it exists
<IfModule mod_rewrite.c>
RewriteRule ^vendor/.*$ - [F,L]
</IfModule>
# Set proper MIME types
<IfModule mod_mime.c>
AddType application/json .json
AddType text/css .css
AddType application/javascript .js
AddType text/html .html
</IfModule>
# Enable compression for better performance
<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
AddOutputFilterByType DEFLATE application/json
</IfModule>
# Cache static files for better performance
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/ico "access plus 1 month"
ExpiresByType image/icon "access plus 1 month"
ExpiresByType text/plain "access plus 1 month"
</IfModule>
# PHP Configuration (if allowed)
<IfModule mod_php8.c>
# Increase memory limit for large directory structures
php_value memory_limit 256M
# Increase execution time for deep scans
php_value max_execution_time 60
# Set timezone
php_value date.timezone "America/New_York"
# Error handling (disable in production)
php_flag display_errors Off
php_flag log_errors On
</IfModule>
# Custom error pages (optional)
ErrorDocument 404 /index.php?error=404
ErrorDocument 403 /index.php?error=403
ErrorDocument 500 /index.php?error=500