Skip to content

Instantly share code, notes, and snippets.

@u1735067
Last active December 15, 2019 00:29
Show Gist options
  • Save u1735067/05e58782fa044f78c37fef224758adf1 to your computer and use it in GitHub Desktop.
Save u1735067/05e58782fa044f78c37fef224758adf1 to your computer and use it in GitHub Desktop.
htaccess to display the resume PDF in the locale matching the requested subdomain
# Display the PDF when possible, instead of downloading it
<FilesMatch "My Name - CV (?<CV_LANG>[A-Z]{2})\.pdf">
# https://stackoverflow.com/questions/93551/how-to-encode-the-filename-parameter-of-content-disposition-header-in-http
# https://tools.ietf.org/html/rfc5987
Header set "Content-disposition" "inline; filename=\"My Name - CV %{MATCH_CV_LANG}e.pdf\"; filename*=UTF-8''My%%20Name%%20-%%20CV%%20%{MATCH_CV_LANG}e.pdf"
</FilesMatch>
# Finally, default to FR
SetEnvIf HOST "^resume\." CV_LANG=EN
SetEnvIf CV_LANG ^$ CV_LANG=FR
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} "!=/favicon.ico"
RewriteRule ".*" "My Name - CV %{env:CV_LANG}.pdf" [L]
#<Files "favicon.ico">
# FallbackResource disabled
#</Files>
#FallbackResource "/My Name - CV FR.pdf"
# # Fails when entering the If case : favicon.ico would return the PDF
#<If "%{HTTP_HOST} =~ /^resume\./">
# FallbackResource "/My Name - CV EN.pdf"
#</If>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment