Added .htaccess rules to deny access to hidden files. Escaped JSON output in views to prevent XSS attacks. Converted delete links and forms to use POST with CSRF tokens. Enforced POST method on sensitive routes. Added tests to verify these security controls.
43 lines
1.4 KiB
ApacheConf
43 lines
1.4 KiB
ApacheConf
<FilesMatch "^\.">
|
|
Require all denied
|
|
</FilesMatch>
|
|
|
|
<IfModule mod_rewrite.c>
|
|
RewriteEngine On
|
|
RewriteRule (^|/)\.(?!well-known/) - [F,L]
|
|
|
|
# Redirect non-www. to www. (except when on a subdomain)
|
|
# RewriteCond %{HTTP_HOST} !^www\.
|
|
# RewriteCond %{HTTP_HOST} !^(.*)\.(.*)\. [NC]
|
|
# RewriteRule ^ https://www.%{HTTP_HOST}/$1 [R=301,L]
|
|
|
|
# Redirect HTTP to HTTPS
|
|
# RewriteCond %{HTTPS} !=on
|
|
# RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
|
|
|
|
# Remove any trailing slashes from non-directories using a redirect
|
|
# RewriteCond %{REQUEST_FILENAME} !-d
|
|
# RewriteCond %{REQUEST_URI} (.+)/$
|
|
# RewriteRule ^ %1 [R=301,L]
|
|
|
|
# Rewrite /themes/{theme}/{file} to /themes/{theme}/public/{file}
|
|
RewriteRule ^themes/([^/]+)/(?!public/)(.*)$ themes/$1/public/$2 [L]
|
|
|
|
# Rewrite non-directory and non-file URLs to index.php
|
|
# RewriteCond %{REQUEST_FILENAME} !-d
|
|
# RewriteCond %{REQUEST_FILENAME} !-f
|
|
# RewriteRule ^ index.php [L]
|
|
|
|
# Allow direct access to theme files with URL format: /themes/{theme}/public/{file}
|
|
RewriteRule ^themes/([^/]+)/public/(.*)$ themes/$1/public/$2 [L]
|
|
|
|
# Allow direct access to uploaded files with URL format: /uploads/{filepath;,}
|
|
RewriteRule ^uploads/.*\.(?:php[0-9]*|phtml|phar)(?:/|$) - [F,NC]
|
|
RewriteRule ^uploads/(.*)$ uploads/$1 [L]
|
|
|
|
# Rewrite all remaining requests to index.php
|
|
# RewriteRule ^ index.php [L]
|
|
</IfModule>
|
|
|
|
FallbackResource /index.php
|