Skip to content

Basic example for the htaccess configuration for a CDN like cloudfront etc. #33284

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: 2.4-develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions pub/media/.htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,21 @@ AddType application/xml xml

</IfModule>

#CDN Example like cloudfront + Sub/Multidomain support
#remove line 76-86, comment out line 90-101, line 92 "domain.com|domain.de" change/add the required domains
#<IfModule mod_headers.c>
# <FilesMatch .*\.(ico|gif|png|jpg|jpeg|svg|svgz|webp|avif|avifs|js|css|eot|ttf|otf|woff|woff2)$>
# SetEnvIf Origin "http(s)?://(.+\.)?(domain.com|domain.dev)$" AccessControlAllowOrigin=$0
# Header set Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
# Header set Access-Control-Allow-Credentials true
# Header append Cache-Control max-age=604800
# </FilesMatch>
#
# <FilesMatch .*\.(zip|gz|gzip|bz2|csv|xml)$>
# Header append Cache-Control no-store
# </FilesMatch>
#</IfModule>

<IfModule mod_expires.c>

############################################
Expand Down
19 changes: 19 additions & 0 deletions pub/static/.htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,25 @@ AddType application/xml xml

</IfModule>

#CDN Example like cloudfront + Sub/Multidomain support
#remove line 75-85, comment out line 89-104, change line "domain.com|domain.dev" to your domains
#<IfModule mod_headers.c>
# <FilesMatch .*\.(ico|gif|png|jpg|jpeg|svg|svgz|webp|avif|avifs|js|css|eot|ttf|otf|woff|woff2|html|json|manifest|webmanifest)$>
# SetEnvIf Origin "http(s)?://(.+\.)?(domain.com|domain.dev)$" AccessControlAllowOrigin=$0
# Header set Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
# Header set Access-Control-Allow-Credentials true
#
# Header set Cache-Control "max-age=604800, public"
# Header set Access-Control-Allow-Methods "GET, HEAD, OPTIONS"
# Header set Access-Control-Max-Age "604800"
# Header set Access-Control-Allow-Headers "Host, Origin, X-Requested-With, Content-Type, Accept"
# </FilesMatch>
#
# <FilesMatch .*\.(zip|gz|gzip|bz2|csv|xml)$>
# Header append Cache-Control no-store
# </FilesMatch>
#</IfModule>

<IfModule mod_expires.c>

############################################
Expand Down