Skip to content

Instantly share code, notes, and snippets.

@mrkrash
Created April 30, 2024 14:11
Show Gist options
  • Save mrkrash/1c26df096795256871664ad7e9fd11c1 to your computer and use it in GitHub Desktop.
Save mrkrash/1c26df096795256871664ad7e9fd11c1 to your computer and use it in GitHub Desktop.
Caddy configuration for prestashop - rewrite rules
{
log {
output stdout
format console
level DEBUG
}
supervisor {
php-fpm {
restart_policy always
redirect_stdout stdout
redirect_stderr stderr
}
}
}
*:80 {
@rule1 path_regexp rule1 ^/(\p{Nd})(\-\w*)/.+(\.(?:jpe?g|webp|png|avif))$
@rule2 path_regexp rule2 ^/(\p{Nd})(\p{Nd})(\-\w*)/.+(\.(?:jpe?g|webp|png|avif))$
@rule3 path_regexp rule3 ^/(\p{Nd})(\p{Nd})(\p{Nd})(\-\w*)/.+(\.(?:jpe?g|webp|png|avif))$
@rule4 path_regexp rule4 ^/(\p{Nd})(\p{Nd})(\p{Nd})(\p{Nd})(\-\w*)/.+(\.(?:jpe?g|webp|png|avif))$
@rule5 path_regexp rule5 ^/(\p{Nd})(\p{Nd})(\p{Nd})(\p{Nd})(\p{Nd})(\-\w*)/.+(\.(?:jpe?g|webp|png|avif))$
@rule6 path_regexp rule6 ^/(\p{Nd})(\p{Nd})(\p{Nd})(\p{Nd})(\p{Nd})(\p{Nd})(\-\w*)/.+(\.(?:jpe?g|webp|png|avif))$
@rule7 path_regexp rule7 ^/(\p{Nd})(\p{Nd})(\p{Nd})(\p{Nd})(\p{Nd})(\p{Nd})(\p{Nd})(\-\w*)/.+(\.(?:jpe?g|webp|png|avif))$
@rule8 path_regexp rule8 ^/c/([\d]+)?-([a-zA-Z_-]+)/.+(\.(?:jpe?g|webp|png|avif))$
@rule9 path_regexp rule9 ^/images_ie/?([^/]+)\.(jpe?g|png|gif)$
rewrite @rule1 /img/p/{re.rule1.1}/{re.rule1.1}{re.rule1.2}{re.rule1.3}
rewrite @rule2 /img/p/{re.rule2.1}/{re.rule2.2}/{re.rule2.1}{re.rule2.2}{re.rule2.3}{re.rule2.4}
rewrite @rule3 /img/p/{re.rule3.1}/{re.rule3.2}/{re.rule3.3}/{re.rule3.1}{re.rule3.2}{re.rule3.3}{re.rule3.4}{re.rule3.5}
rewrite @rule4 /img/p/{re.rule4.1}/{re.rule4.2}/{re.rule4.3}/{re.rule4.4}/{re.rule4.1}{re.rule4.2}{re.rule4.3}{re.rule4.4}{re.rule4.5}{re.rule4.6}
rewrite @rule5 /img/p/{re.rule5.1}/{re.rule5.2}/{re.rule5.3}/{re.rule5.4}/{re.rule5.5}/{re.rule5.1}{re.rule5.2}{re.rule5.3}{re.rule5.4}{re.rule5.5}{re.rule5.6}{re.rule5.7}
rewrite @rule6 /img/p/{re.rule6.1}/{re.rule6.2}/{re.rule6.3}/{re.rule6.4}/{re.rule6.5}/{re.rule6.6}/{re.rule6.1}{re.rule6.2}{re.rule6.3}{re.rule6.4}{re.rule6.5}{re.rule6.6}{re.rule6.7}{re.rule6.8}
rewrite @rule7 /img/p/{re.rule7.1}/{re.rule7.2}/{re.rule7.3}/{re.rule7.4}/{re.rule7.5}/{re.rule7.6}/{re.rule7.7}/{re.rule7.1}{re.rule7.2}{re.rule7.3}{re.rule7.4}{re.rule7.5}{re.rule7.6}{re.rule7.7}{re.rule7.8}{re.rule7.9}
rewrite @rule8 /img/c/{re.rule8.1}-{re.rule8.2}{re.rule8.3}
rewrite @rule9 /js/jquery/plugins/fancybox/images/{re.rule9.1}.{re.rule9.2}
root * /srv/www
php_fastcgi unix//run/php-fpm.sock {
dial_timeout 60s
capture_stderr
}
file_server
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment